: Unfortunately not.... the javadoc says it comes from the web.xml : : java.lang.String getServletContextName() : 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.
Yeah, but if we don't put a display name in the web.xml, it's the name of the webapp directory. (or at least that's the way it works on Resin). There's also HttpServletRequest.getContextPath() .. it will work regardless of display-name, but it requires a request object. Toss the attached index.jsp into a couple of differnet webapp directories, then toss the web.xml into one of those webapps, and you'll see what i mean.
<html> <head><title>test</title></head> <body> Context Path: <%= request.getContextPath() %> <br /> Application Context Name: <%= application.getServletContextName() %> <br />
web.xml
Description: application/xml