On Mon, 1 Oct 2001, chiuming wrote:

> Date: Mon, 1 Oct 2001 18:19:09 -0700 (PDT)
> From: chiuming <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: get Servlet Context Name
>
> hi,
> any way I can get a servlet context ( web application
> )'s name with in a servlet?  on Servlet API 2.2 (not
> Servlet 2.3)
>

There is no such thing as a servlet context "name" in servlet 2.2.  In
servlet 2.3, the context "name" is just a visual prompt for use in
deployment tools -- it doesn't have anything at all to do with request
processing.   What are you trying to accomplish by asking for the name?

If you are after the servlet context *path* (i.e. what goes on the front
of the URL), you can get that (in either 2.2 or 2.3) by calling
request.getContextPath(), but this only works when processing a request,
not during the init() method.

> -OR- there is no way to do that?
>
> P.S. I am using tomcat... may I access internal tomcat
> object to achieve that?
>
> thanks

Craig McClanahan


Reply via email to