I apologized for posting the question but I have seen over servlet api
questions posted.
Here is the solution that I implemented. I was looking for the context path
in the init method of a servlet.

public class MyServlet extends HttpServlet {
   :
   public void init(ServletConfig config) {
       super.init(config);
       // get context path for this servlet
       try {
         s_contextPath =
config.getServletContext().getResource("/").getPath();
         if ( s_contextPath.equals("/") ) s_contextPath = "";
       }
       :
   }


----- Original Message ----- 
From: "Gerhard Kreutzer" <[EMAIL PROTECTED]>
To: "Tomcat Developers List" <[EMAIL PROTECTED]>
Sent: Saturday, July 26, 2003 2:23 AM
Subject: Re: Can I get the webapp context path from the init method of a
servlet


> Stephen Ince wrote:
>
> >I am trying to get the context path from the javax.servlet API  for a
> >servlet when it is being initialized (init) and not when it is invoked
(not
> >via service, doGet, doPost ..).
> >I know that I can get it from the request.getContextPath() method but
this
> >can only be done when the
> >servlet is invoked.
> >
> >
> >
> I think this is *not* a question for tomcat-dev list..
>
> ServletConfig#getServletContext()
> GenericServlet#getServletContext()
>
> -- 
> KreutzerSoft
> B�renb�hlgraben 76, 90475 N�rnberg
> Tel: +49-911-8324-57
> Fax: +49-911-8324-61
> mailto:[EMAIL PROTECTED]
> http://www.KreutzerSoft.de
>
>
>
> ---------------------------------------------------------------------
> 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