PDA

View Full Version : Sub-contexts in Tomcat: deploy your webapps as /bar/foo instead of /foo


kjkoster
21-06-2009, 12:12
Dear All,

Tomcat has the notion of sub contexts. Contexts, as you know, are the names of the web applications. Context names always serve as the base for your URLs. So, a web application named foo will end up accessible through http://www.example.com/foo/.

Sometimes you'd like to deploy a web application not as http://www.example.com/foo/, but as http://www.example.com/bar/foo. You can do this when you are using context files in ${tomcat}/conf/Catalina/localhost. I you place a file there named bar#foo.xml, Tomcat will expose that web application on http://www.example.com/bar/foo/.

Please note that this feature is specific to Tomcat. It is not part of the servlet specification. If your app has even the slightest chance of being ported to different JEE servers, you should not be relying on this feature.

Kees Jan