tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Green, Jeffrey" <jeffrey.gr...@lehman.com>
Subject RE: Webapp names and paths within JSPs for images
Date Thu, 08 Jan 2004 20:53:47 GMT
I'm running into the exact same issue.  It seems that you could use
HttpServletRequest.getContextPath() or parse through
HttpServletRequest.getRequestURI() to get the root-relative path of the URL.
Then prepend that with the image name (or do whatever manipulation is
necessary).  I've found it tougher to actually get a webapp deployed "using
any 'name' I'd like".  Hod did you get that working?

-----Original Message-----
From: David Wall [mailto:d.wall@computer.org] 
Sent: Thursday, January 08, 2004 3:43 PM
To: Tomcat Users List
Subject: Webapp names and paths within JSPs for images


In theory I should be able to take my webapp (starting with the base
directory that contains the WEB-INF subdirectory) and deploy it using any
"name" I'd like, so I could easily deploy the same webapp with URLs like
http://mydomain.com/ (using the root context) or http://mydomain.com/app1/
or even http://mydomain.com/app2/ etc.

However, JSPs can include files using the "/" root to indicate I'm talking
about a file at the top of the webapp directory and that works fine.  But
images need to include URLs that that aren't processed by tomcat (so it
doesn't know about the webapp's "base" directory), so I have to use names
like "/images/image.gif" or "/app1/images/image.gif" or
"/app2/images/image.gif" depending on where the webapp was actually
deployed.

While I can use relative paths for such images much of the time, when using
servlets that redirect/forward or whatever, the "current directory" is not
always the same, so you can't just use "images/image.gif" or
"../images/image.gif" to make it work.

How are people coding their JSPs and servlets that return IMG tags so that
the images can always be defined without including the webapp path name?

Thanks,
David


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


------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the
designated recipient(s) named above.  If you are not the intended recipient of
this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited.  This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be
secure or error-free.  Therefore, we do not represent that this information is
complete or accurate and it should not be relied upon as such.  All
information is subject to change without notice.


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


Mime
View raw message