I need to access the contextRoot or webapp name from a startup servlet deployed in WebLogic. I've tried the following;
getServletContext().getRealPath("/") return null.
getServletContext().getServerInfo() returns Weblogic 8.1 service pack 3...
getServletContext().getServletContextName() display the <display-name> value from my web.xml.
What I want is the <context-root> value in the EARs application.xml.
I tried the following JNDI lookup and the lookup failed but the error message contained the contextRoot.
Any help would be GREATLY appreciated. This should be easy!!
Oops. Forgot to include the jndi lookup..
Here it is;
String name = (String) jndiContext.lookup("java:/comp/env/namespace");
log.info("jndiContextlookup namespace = "+name);
Thanks in advance.
What you're looking for a way to get the value returned from HttpServletRequest.getContextPath() via the ServletContext interface, right? You are right; that SHOULD be easy, but I don't see anywhere in the API that it's possible. Are you sure you need the value outside the scope of a request?
Thanks for taking the time to respond. The web/enterprise application is deployed on an application server and it never receives HTTP requests. It's purpose is to read from and write to JMS queues.
We are employing JMX MBeans and we need a facility to identify which webapp the MBeans are related to i.e.
There has to be a way to do this.