aspose file tools
The moose likes Servlets and the fly likes Get webapp name with ServletContext Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Get webapp name with ServletContext" Watch "Get webapp name with ServletContext" New topic
Author

Get webapp name with ServletContext

Stephane Philippart
Greenhorn

Joined: Jul 29, 2004
Posts: 12
Hi everybody,

I have the following problem : i wrote a webapp which is deployed under Tomcat , this webapp is for several clients with a custom name for each of them.

I need to get the name of the webapp to put it in the database. I want to read the name at the startup of the Tomcat. So i try to write a custome Listner but i only access to the ServletContext and i can't find the way to get the name !

I don't want specially write a listner so if you have another solution to solve my problem i am ok !

Thanks

Stef
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Try to use getServletContextName() method.
API tells

Returns the name of this web application corresponding to this ServletContext as specified in the deployment descriptor for this web application by the display-name element.


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Stephane Philippart
Greenhorn

Joined: Jul 29, 2004
Posts: 12
unfortunatly this method return the name put in the web.xml not the name of the webapp in the Tomcat.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Get webapp name with ServletContext
 
Similar Threads
needs help: context -entry in server.xml
adapter class !!
How to get WebApplication name, not the DisplayName
Any Solution to Break/Overlook the Session Variables ?
Get the webapp name configured in Tomcat