You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Shapira, Yoav" <Yo...@mpi.com> on 2002/06/25 18:19:31 UTC

Servlet knowing its own URL

Howdy,
I'm probably missing something basic here ;)  But how can a Servlet know
its own URL at startup, before any requests are sent to it?

More specifically, if I have a webapp MyApp, and a servlet MyServlet,
accessible as
http://myhost.mydomain:myport/MyApp/MyServlet

I would like MyServlet's init() method to figure out that its context is
at
http://myhost.mydomain:myport/MyApp

Any ideas, suggestions etc. much appreciated ;)

Yoav Shapira
Millennium ChemInformatics



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Servlet knowing its own URL

Posted by Mike Jackson <mj...@cdi-hq.com>.
You can get the name from getServletName, I think the rest of what
you're looking for can be acquired from the servlet context, but
I might be wrong.

--mikej
-=-----
mike jackson
mjackson@cdi-hq.com

> -----Original Message-----
> From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com]
> Sent: Tuesday, June 25, 2002 9:20 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Servlet knowing its own URL
>
>
> Howdy,
> I'm probably missing something basic here ;)  But how can a Servlet know
> its own URL at startup, before any requests are sent to it?
>
> More specifically, if I have a webapp MyApp, and a servlet MyServlet,
> accessible as
> http://myhost.mydomain:myport/MyApp/MyServlet
>
> I would like MyServlet's init() method to figure out that its context is
> at
> http://myhost.mydomain:myport/MyApp
>
> Any ideas, suggestions etc. much appreciated ;)
>
> Yoav Shapira
> Millennium ChemInformatics
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>