title: Specifying the Servlet and JSP version of my Java web application
body: <p>Does the "web-app_*.dtd" reference web.xml determine the Servlet and JSP version used in the web application ?</p>
  
  <p>Somehow I have been under that impression, but it seems like I am wrong. I have an application where the web.xml specifies</p>
  
  <pre><code>&lt;!DOCTYPE web-app PUBLIC
      "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd"&gt;
  </code></pre>
  
  <p>I was thinking that it should be using Servlet version 2.3. However, when I put the following code in my JSP, I get a totally different version.</p>
  
  <pre><code>&lt;div&gt;
  Server info: &lt;%= application.getServerInfo() %&gt;&lt;br&gt;  
  Servlet version: &lt;%= application.getMajorVersion() %&gt;.&lt;%= application.getMinorVersion() %&gt;  
  JSP version: &lt;%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %&gt;&lt;br&gt; 
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>Server info: Apache Tomcat/7.0.21
  Servlet version: 3.0
  JSP version: 2.1
  </code></pre>
  
  <p>I will appreciate help with a few related questions:.</p>
  
  <ul>
  <li>Does the dtd version have any bearing on the Servlet and JSP version used in the application ?</li>
  <li>Is my application using Servlet version 3.0 because that is the default version being used by Apache Tomcat 7 ?</li>
  <li>Is there any way to make Tomcat 7, use an older Servlet JSP version ?</li>
  <li>One of the comments (by Bauke Scholtz) on <a href="http://www.coderanch.com/t/425693/java-Web-Component-SCWCD/certification/know-which-servlet-jsp-version" rel="nofollow">this page</a>, seems to suggest that every Servlet version is tied to a JSP version. Is this always true ?</li>
  </ul>