request.getContextPath() should supply what you need. If the webapp is the ROOT webapp, it will return an empty string. That just makes it easy to write stuff like:

<img src="${pageContext.request.contextPath}/images/myMasthead.jpg" />

If you really need the ROOT webapp to return "/", then you'll just have to test for an empty string and handle that as a special case.

--David

santhoshihrd wrote:
Hi all,
I have an issue I have a context nemed "demo" with the following configuration <Context path="/demo" docBase="webapps/MyWebApp.war" debug="0" privileged="true">
</Context>

I want to get the context name "demo" in a servlet . I am using Spring
framework. It will be more usefule if I get it in Dispatcher servlet. If I
am deploying the context in "/" , I should get it as "/"
<Context path="/" docBase="webapps/MyWebApp.war" debug="0" privileged="true">
</Context>

Thanks in advance




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to