tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <res0o...@verizon.net>
Subject Re: Moving between JSPs and Servlets within a webapp
Date Sat, 24 Aug 2002 06:51:44 GMT
In your example, request.getContextPath() will return "/myapp".  So code in
your JSP page that looks like:
<a href="<%= request.getContextPath() %>/servlet/myservlet">Cool Servlet</a>

should do what you want.

"Anthony Nolan" <anolan@bigpicture.ie> wrote in message
news:NOEKLBLJIEIMDICEBHNNCEKKCBAA.anolan@bigpicture.ie...
> Hi,
>
> I have a webapp which contains servlets and jsp pages. In development I
keep
> all jsp pages in a subdirectory of the project called 'jsp'. When I deploy
> to production I use a war file and specify that the contents of the jsp
> directory is to be included in the war. This expands on the production
> server with the jsp files in the root of the webapp.
> i.e. in development I use the url:
> http://localhost:8080/myapp/jsp/myfile.jsp
> in production the url is http://prodserver:8080/myapp/myfile.jsp
>
> this works fine except when I must redirect to a servlet from a jsp page.
I
> can set up the path to redirect to so that it works in development (for
> example ..\servlet\myservlet), but then when I deploy to production the
> relative references no longer work. I could filter the files with ant and
> remove the relative references at deployment time, but would prefer a more
> robust solution. Is there some way I can get a reference to a Context
object
> and then find my servlets relative to this?
> I am using tomcat 3.3.1 and JDK 1.3.
>
> Can anyone help with this?
>
> Thanks
>
> Anthony Nolan
> Big Picture Software
>
>
> This E-mail and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this E-mail in error please notify us
immediately and delete this E-mail from your system. Thank you.
> It is possible for data transmitted by email to be deliberately or
> accidentally corrupted or intercepted. For this reason, where the
> communication is by E-mail, the Big Picture Group does not accept
> any responsibility for any breach of confidence which may arise through
the use of this medium.
> Opinions, conclusions and other information in this message that do not
relate to the official business of Big Picture Group shall be understood as
neither given nor endorsed by it.
> This footnote also confirms that this email message has been swept for the
presence of known computer viruses.





--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message