You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Martin Bromley <ma...@sustainable-energy.co.uk> on 2005/07/22 13:16:03 UTC

getServletContext() returns "/" for default context defined outside of server.xml

Hi, I'm trying to setup the default Context for a Host, without defining it in server.xml.

In conf/Catalina/localhost I've created a file named .xml, and defined the Context within it, without defining the path - I understand from the Tomcat docs that it should be inferred as "".

This is all working fine, apart from one issue:  a call to HttpServletRequest.getServletContext() returns "/" rather than "" - the servlet API says "" is correct .  If the default context is defined in server.xml, getServletContext() returns "" as it should.

I'm guessing that this might be a bug, but I'm reluctant to say so because I suspect I might be doing something wrong - the Tomcat docs do say "it is not recommended to place <Context> elements directly in the server.xml file", but then creating a .xml file seems a little odd to me...  Is that really the right way to do it?

I've tested this on Tomcat 5.5.4 and 5.5.7.

Cheers
Martin


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org