dcsimg
Re[2]: How to get context root of a web application
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abhay_Shukla
Posted On:   Wednesday, March 1, 2006 11:06 AM

This is true for a servlet that gets invoked upon a request. What about a servlet which is initialized on application start up ? In the init() method, request object cannot be accessed.

Re[3]: How to get context root of a web application

Posted By:   Christopher_Koenigsberg  
Posted On:   Sunday, March 5, 2006 12:08 AM

There is a ServletContext.getServletContextName() I think (look it up). It will return the value that your web.xml has in the "display-name" (I think; look it up to be sure). I don't think this is guaranteed in the J2EE specs but it works on WebSphere, WebLogic, Tomcat, and JBoss...



If you make sure this is the same as your context root, you can use it, as long as you can get a ServletContext.
About | Sitemap | Contact