Search code examples
tomcatservletsjettyjava-8cometd

Which servlet-api jar should I use for my cometd filter


I am using cometd 3.0.1 and trying to deploy it in tomcat 7.0.50. I have some filter created, previously I was using jetty jar (9.2.2) to compile these filter classes, but after move from jetty which jar should I include in my class path.

I want jar so that I don't need to regenerate my war every time I move from one container to other.

Can I include servlet api jar directly from jdk (I am unable to find jar in my jdk). I am using java 8.


Solution

  • The documentation home page of Tomcat 7 says:

    Apache Tomcat version 7.0 implements the Servlet 3.0 and JavaServer Pages 2.2 specifications

    So, you need the 3.0 version of the servlet API.

    The Servlet API is not part of Java SE. It's part of Java EE. So you won't find it in the JDK. You only need the jar to compile your code.

    Note that whether you use Jetty or Tomcat doesn't change anything: this jar is provided by the servlet container, so it must NOT be inside the war file. You can find the jar that Tomcat uses in the lib directory of Tomcat.