Alright, this is a very simple question. I just installed Tomcat 6 on my Mac to play around with it, and every tutorial I look at says the first thing to do to create a new web application is to add a line to the server.xml file with defines a new Context. Fair enough. However, my question is, I don’t see a line in there for the example web applications, so how do those work?
Alright, this is a very simple question. I just installed Tomcat 6 on my
Share
The sample web applications use the default host defined in
$CATALINA_HOME/conf/server.xml:Notice the
appBaseattribute (which is defined relative to$CATALINA_HOME). If you drop a.warfile in that folder, it will be auto-deployed as a context in the default host. Tomcat will dynamically create a context if none is defined in$CATALINA_HOME/conf/server.xml(actually there are a couple of other places contexts can be defined too but that is outside the scope of this discussion).So for example, if you drop a war file named
mycontext.warin$CATALINA_HOME/webapps, you’ll be able to reach it with your web browser at the urlhttp://localhost:8080/mycontext/(assuming you haven’t changed the default port and autoDeploy settings that tomcat ships with). This is how the examples that ship with tomcat are set up.