Search code examples
javaapachetomcatservletsseam

Can I use Apache Tomcat 7 with servlet api 2.5


There is a leak with tomcat 6, so I am upgrading to tomcat 7.082 which uses servlet api 3.0.

I have deployed the war file which uses servlet 2.5 to Apache tomcat 7.0.82. the app is running is fine and i do not see any immediate issues.

so my question is, is it OK to do this? I will eventually be rolling out this change to production...


Solution

  • Tomcat 7 will run a Servlet 2.5 application just fine. The biggest thing is to make sure your web.xml specifies the version. So, for your example, it would look something like:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
              http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
              version="2.5">
    
        ...
    
    </web-app>
    

    This tells the container (Tomcat in this case) that this web application follows the Servlet 2.5 spec.