ServletContext.getRealPath("/") works for me.Thanks.
    On Tuesday, August 13, 2019, 01:43:35 AM PDT, Mark Thomas 
<> wrote:  
 On 12/08/2019 23:18, W wrote:
> Hi,
> I would like to find the war file name (for example, 
> ROOT##2019-08-12-10-44.war) inside  
> ServletContextListener.contextInitialized() and 
> ServletContextListener.contextDestroyed(). So I can send email to admins warn 
> them which app is up and down. 
> Is there a way to do it?

It isn't guaranteed to work in all circumstances but try:


If that doesn't work then - assuming you can use reflection - something
along these lines:

Obtain the ServletConext.
Cast it to org.apache.catalina.core.ApplicationContext

Use reflection to read the context field or call getContext() which will
return a StandardContext instance.

Then you have various options:
- call getDocbase()
- call getPath() and getWebappVersion()

and there are probably plenty of other similar approaches that would work.


To unsubscribe, e-mail:
For additional commands, e-mail:


Reply via email to