JavaRanch Home    
 
This page:         last edited 14 October 2010         What's Changed?         Edit

Servlets Web Xml   

How do I declare the web.xml file for Servlets 3.0 and JSP 2.1? (Tomcat 7, and so on)
<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">
    <!-- rest of declarations go here -->

</web-app>

How do I declare the web.xml file for Servlets 2.5 and JSP 2.1? (Tomcat 6, and so on)

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>web app name here</display-name>

    <!-- rest of declarations go here -->

</web-app>

How do I declare the web.xml file for Servlets 2.4 and JSP 2.0? (Tomcat 5, Resin 3, and so on)

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
     version="2.4">

    <display-name>web app name here</display-name>

    <!-- rest of declarations go here -->

</web-app>

Be sure that you do not leave a DOCTYPE declaration from a previous version of the Servlets Specification in this file.

Be aware that this is the manner in which the deployment descriptor must be configured in order for the JSP 2.0 EL (Expression Language) to be enabled on JSP pages by standards-compliant containers such as Tomcat.


ServletsFaq JspFaq

JavaRanchContact us — Copyright © 1998-2014 Paul Wheaton