You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vijayanand Sukumar <VS...@manage.com> on 2000/11/30 10:41:09 UTC

How to get webapp context path from javax.servlet API?

Hi ,
I need to know if there is a way to get the context path from without
creating  a dependency on tomcat. If my web-app context is /foo and I want
to convert a  URL relative to the current context back into an external URL
with the full  syntax.
Thanks
Vijayanand Sukumar
Software Engineer
Manage.com
eManagement for eBusiness
www.manage.com
2345 North First St.,
San Jose, CA 95131
Tel: 408-944-1500 ext. 651
Fax: 408-944-1599
VSukumar@manage.com


Re: How to get webapp context path from javax.servlet API?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Vijayanand Sukumar wrote:

> Hi ,
> I need to know if there is a way to get the context path from without
> creating  a dependency on tomcat. If my web-app context is /foo and I want
> to convert a  URL relative to the current context back into an external URL
> with the full  syntax.

When processing a servlet request, simply call

    String contextPath = request.getContextPath();

and you can use this value to construct an absolute URL.

>
> Thanks
> Vijayanand Sukumar

Craig McClanahan