What would I need to change when I upgrade my servlet from JServ to Tomcat? -- 02.06.01

Ryan Breidenbach



Well, there isn't any reason that your servlet itself would have any specific code in it that would not allow it to be deployed on Tomcat. By this, I mean the code in the init, service, deGet, etc. methods should be servlet-container independent.

That being said, all you should have to do it register the new servlet with Tomcat. This requires modifing two files, server.xml and web.xml.

The server.xml file is where you will register your web application (the context in which your servlet will operate). This would look something like this:

  <!-- other stuff here -->
  <ContextManager debug="0" workDir="workDir" >
    <!-- other stuff here -->
    <!-- your context -->
    <Context path="/myApp" docBase="webapps/myApp" debug="0" reloadable="true" / >

The web.xml file is where you will configure your web application. This includes configuring your servlet's alias and initial parameters. This would look something like:


See the Tomcat Users Guide for more details.