tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vijayanand Sukumar <>
Subject How to get webapp context path from javax.servlet API in init me thod?
Date Fri, 01 Dec 2000 07:04:36 GMT
Can I get the context path in the init() method of the server because i do
not have a request object there???


-----Original Message-----
From: Craig R. McClanahan []
Sent: Thursday, November 30, 2000 10:22 AM
Subject: Re: How to get webapp context path from javax.servlet API?

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
> 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

View raw message