Is there any way of getting the context path, (for example, /myapp), from within the Servlet.init() method. I know I can easily get it with the request object using request.getContextPath(), but I can't figure out how to get it from the init() method.
Discussions
Web tier: servlets, JSP, Web frameworks: Application Context from within Servlet.init()?
-
Application Context from within Servlet.init()? (2 messages)
- Posted by: Greg Barrett
- Posted on: September 11 2002 12:22 EDT
Threaded Messages (2)
- Application Context from within Servlet.init()? by joseph yi on September 13 2002 17:51 EDT
- Application Context from within Servlet.init()? by Greg Barrett on September 23 2002 11:11 EDT
-
Application Context from within Servlet.init()?[ Go to top ]
- Posted by: joseph yi
- Posted on: September 13 2002 17:51 EDT
- in response to Greg Barrett
You can easily get the application context:
public void init(ServletConfig config) throws ServletException {
// see?
ServletContext ctx = config.getServletContext();
}
hope this helped!
-
Application Context from within Servlet.init()?[ Go to top ]
- Posted by: Greg Barrett
- Posted on: September 23 2002 11:11 EDT
- in response to joseph yi
But I can't get the servlet path from the context, which is what I want. I want to get string "/context" which is defined for this servlet.
Specifically, I want to get the same information that I can get from the HttpServletRequest.getContextPath() method.