You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Wang, Jianming" <Ji...@tfn.com> on 2001/08/09 20:07:16 UTC

Absolute URL

Hi, 

Is there a way to know a resource's absolute URL?  I have a image, say
img1.gif.  I want to reference it using
http://www.something:port/appName/graphics/img1.gif in jsp page.  How can I
get all these information to create the url?  I use tomcat 3.2 and it
doesn't support ServletContext.getServletContextName().  Could you give me a
help?  Thanks in advance.

Jianming Wang

Re: Absolute URL

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 9 Aug 2001, Wang, Jianming wrote:

> Hi, 
> 
> Is there a way to know a resource's absolute URL?  I have a image, say
> img1.gif.  I want to reference it using
> http://www.something:port/appName/graphics/img1.gif in jsp page.  How can I
> get all these information to create the url?  I use tomcat 3.2 and it
> doesn't support ServletContext.getServletContextName().  Could you give me a
> help?  Thanks in advance.

You don't want the servlet context name -- you want the context
*path*, which you can get by calling request.getContextPath().  The parts
after that come from request.getServletPath() and request.getPathInfo().

> 
> Jianming Wang
> 

Craig