A ServletConfig reference is passed in the call to the init() method of your
servlet. From this you may use the getServletContext() method to get the
context. One thing to remember is that this does not get called until the
servlet is initialized and would be invalidated when it is destroyed. I suggest
you check the API docs for more information.

Robert S. Harper
801.265.8800 ex. 255
> -----Original Message-----
> From: David Wall [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 10, 2004 10:07 AM
> To: Tomcat Users List
> Subject: Re: How to get the context path for a web application?
> 
> > request.getContextPath();
> 
> Is there a way to do it when not serving a web page?  Like in a startup
> servlet that has a ServletConfig/Context, but doesn't have a request?  This
> way, the context could be retrieved once and cached and used in situations
> unrelated to processing a specific HTTP request.
> 
> David
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to