How to find your Servlet, JSP and Server version?

Today when I was doing something my colleague asked me about what version of JSP and Servlet are you using. Untill now I never bothered about this, but later found a way for this. below are the lines of code to know what version of servlet you are running, version of JSP and application server you are running.

Servlet Version :
<%= session.getServletContext().getMajorVersion() %>.
<%= session.getServletContext().getMinorVersion() %>

JSP Version :
<%= JspFactory.getDefaultFactory().getEngineInfo().
getSpecificationVersion()%>

Server Version : <%= application.getServerInfo()%>

3 comments:

bearcatFulton said...

What if the project does not yet compile how do you know what jsp version you are using?

bearcatFulton said...

How do you know what it is if the project does not yet compile?

Sanjeev Kulkarni said...

You can basically check inside your JAR's MANIFEST file under /META-INF/MANIFEST.MF

Contents of this file will be as follows:

Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 3.0
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: javax.servlet
Implementation-Version: 3.0.FR
Implementation-Vendor: Apache Software Foundation