Check out the Java EE version . Servlet version (JSP, JSF, EJB, JPA, etc.) Goes hand in hand with the Java EE version.
- Java EE 8 = Servlet 4.0
- Java EE 7 = Servlet 3.1
- Java EE 6 = Servlet 3.0
- Java EE 5 = Servlet 2.5
- J2EE 1.4 = Servlet 2.4
- J2EE 1.3 = Servlet 2.3
- J2EE 1.2 = Servlet 2.2
Look at the homepage / documentation on the server how it presents itself. For GlassFish , which is currently (since 4.1):
The world's first Java EE 7 application server
So this is Servlet 3.1.
But with a big one , but , this is one thing. Secondly, the webapp version web.xml also plays a role. Not everyone knows that.
If your webapp web.xml declared compliant with servlet 3.1, as shown below,
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> </web-app>
then your webapp will also work in Servlet 3.1 module.
However, if he announced that Servlet 3.0 is lower or even older,
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> </web-app>
then your webapp will work in the Servlet 3.0 compatibility module, even if it is deployed in a container compatible with Servlet 3.1! The above affects ServletContext#getMajorVersion() and getMinorVersion() , so they actually don't say anything about the container, but only about the web server itself.
If your webapp web.xml contains <!DOCTYPE> , regardless of DTD and version, then it will work in the Servlet 2.3 compatibility module, even if a new XSD is announced!
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "java.sun.com/dtd/web-app_2_3.dtd"> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> </web-app>