简体   繁体   中英

Specifying the Servlet and JSP version of my Java web application

Does the "web-app_*.dtd" reference web.xml determine the Servlet and JSP version used in the web application ?

Somehow I have been under that impression, but it seems like I am wrong. I have an application where the web.xml specifies

<!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

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.

<div>
Server info: <%= application.getServerInfo() %><br>  
Servlet version: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %>  
JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %><br> 
</div>

Output:

Server info: Apache Tomcat/7.0.21
Servlet version: 3.0
JSP version: 2.1

I will appreciate help with a few related questions:.

  • Does the dtd version have any bearing on the Servlet and JSP version used in the application ?
  • Is my application using Servlet version 3.0 because that is the default version being used by Apache Tomcat 7 ?
  • Is there any way to make Tomcat 7, use an older Servlet JSP version ?
  • One of the comments (by Bauke Scholtz) on this page , seems to suggest that every Servlet version is tied to a JSP version. Is this always true ?

Does the dtd version have any bearing on the Servlet and JSP version used in the application ?

Yes, that is the one which tells the server in which version the application was developed.

Is my application using Servlet version 3.0 because that is the default version being used by Apache Tomcat 7 ?

No, the server can support 3.0 does not mean your application uses 3.0 Because your application is servlet 2.5, the servlet 3.0 features will be disbled for you.

Is there any way to make Tomcat 7, use an older Servlet JSP version ?

Yes. The answer to the first question, your web.xml

One of the comments (by Bauke Scholtz) on this page, seems to suggest that every Servlet version is tied to a JSP version. Is this always true ?

Mostly Yes. It is not tightly coupled. But every server complies to JavaEE standard, and each JavaEE standard should confirm to some specifications and their versions. For Ex, JavaEE 5 need Servlet 2.5 and JSP 2.1, JavaEE 6 needs Servlet 3.0 and JSP2.2.

Does the dtd version have any bearing on the Servlet and JSP version used in the application ?

Yes.

Is my application using Servlet version 3.0 because that is the default version being used by Apache Tomcat 7 ?

Yes.

Is there any way to make Tomcat 7, use an older Servlet JSP version ?

No, you'll need to get an earlier version of Tomcat.

One of the comments (by Bauke Scholtz) on this page, seems to suggest that every Servlet version is tied to a JSP version. Is this always true ?

Yes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM