How can I get the version of the Servlet API that is being used by a servlet/JSP engine?

John Zukowski

The ServletContext interface includes methods getMajorVersion() and getMinorVersion() to tell you what version of the Servlet API is in use.

[Alex Chaffee adds:]

So, for example, JSWDK 1.0.1, which supports the Servlets spec 2.1, would return "2" for getMajorVersion() and "1" for getMinorVersion().

From a JSP, you can use the implicit application object to access the ServletContext. For example:
Major: <%=application.getMajorVersion()%>
Minor: <%=application.getMinorVersion()%>

Jason Hunter's com.oreilly.servlet package has some code for determining this in an allegedly more robust manner.

See also How can I determine the name and version number of the servlet or JSP engine that I am using?

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact