tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Ruthenbeck <>
Subject RE: URI Servlet Path Problems
Date Wed, 06 Aug 2003 21:54:17 GMT
At 02:37 PM 8/6/2003, you wrote:
>That is pretty much what my understanding was as well.  But I am glad
>you cleared it up for me.  So appending my webapp folder name is not
>"bad practice" then.  It is just something that has to be done.

Depends what you mean.  Appending your webapp folder name in your html 
pages is NOT considered good practice because it locks you in to a specific 
web application name.  There are three good solutions to this problem:

(1) Use Mike's suggestion of using request.getContextPath() when generating 
your html. This would produce code such as (in a jsp):
         <img src="<%request.getContextPath()%>/myServlet"/>

(2) Make all of your URLs relative.  That means doing things like (in html):
         <img src="../myServlet"/>

(3) Maintain all this information in your own configuration files.  I 
prefer this method as it allows for maximum flexibility in deployment (for 
which I'm responsible) -- but that's a different Thread.  Do whatever works 
best for you.  This produces something like (in a jsp):
         <img src="<%MyConfig.getURLPrepend()%>/imageWebApp/myImageServlet"/>


Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com

View raw message