Web.xml__web of Servlet 2.5

Source: Internet
Author: User
Tags valid versions xmlns
2007 March

Sun never publishes the specifications of the servlet versions of Web. XML, and it's hard to find it even if it's online. The servlet container that follows the support will publish some sample programs, good luck, there will be the latest version of Web. XML, for example, the TOMCAT6 version has a servlet 2.5, as follows:

    <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_5.xsd"
    version= "2.5" >

Don't think it's over and it's a pity to tell you that this code is wrong. Do not believe you try to open this link http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd, you will find that is no page found.

That's why Tomcat6 's example program works, because in Tomcat6 's lib, the file already exists, so it doesn't need to be crawled from the network. In fact, you follow this web. xml to write the servlet 2.5 program, in the TOMCAT6 can also be run.

But when I use Eclipse+xmlbuddy, the problem comes out, because Web-app_2_5.xsd has been unable to download, Xmlbuddy has been error, and there is no syntax hint function. By searching, I found the real address of web-app_2_5.xsd is actually http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd, and its namespace is HTTP// Java.sun.com/xml/ns/javaee, the code should be changed to:

    <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_2_5. xsd "
    version=" 2.5 ">

Look at the different parts, in fact, because Sun has renamed the Java EE.

PS, plus the wording of servlet 2.4

    <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" >

What's new in Servlet 2.3:
October 2000 Out
The most significant change in Servlet API 2.3 is the addition of filters


What's new in Servlet 2.4:
November 2003 out
1. The Web. XML DTD has been converted to the Schema.
Versions prior to Servlet 2.3 used the DTD as the definition of the deployment profile, with the format of Web. Xml as follows:
<?xml version= "1.0" encoding= "Is0-8859-1"?>
<! DOCTYPE Web-app
Public "-//sunmicrosystems,inc.//dtd WebApplication 2.3f//en"
"Http://java.sun.com/j2ee/dtds/web-app_2.3.dtd" >
<web-app>
.......
</web-app>


For the first time, Servlet version 2.4 uses XML Schema definitions as deployment profiles, which makes it easier for web containers to validate the. XML syntax. At the same time, the XML Schema provides better extensibility, and its format in Web. HTML is as follows:
<?xml version= "1.0" encoding= "UTF-8"?>
<web-app version= "2.4" xmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE"
xmlns:workflow= "Http://www.workflow.com"
Xmins: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 ">
.........
</web-app>
Note: After changing to schema, there are two main enhancements:
(1) elements are not set according to order
(2) More powerful verification mechanisms
Mainly reflected in:
A. Checking whether the value of an element is a valid value
B. Check whether the value of the element is a valid literal character or a numeric character
C. Check if the names of the elements, such as servlet,filter,ejb-ref, are unique
2. Add filter Four settings: REQUEST, FORWARD, include, and error.
3. Add request Listener, event and request Attribute Listener, enent.
4. Cancel the Singlethreadmodel interface. When the servlet implements the Singlethreadmodel interface, it ensures that only one thread can execute the servlet at the same time.
5.<welcome-file-list> can be a servlet.
Some new methods are added to the 6.ServletRequest interface.
Public String Getlocalname ()
Public String getlocaladdr ()
public int Getlocalport ()
public int Getremoteport ()


New features of Servlet 2.5
September 2005 Release Servlet 2.5
Servlet2.5 Introduction to some changes:
1) developed based on the latest J2SE 5.0.
2) Support annotations.
3) several configurations in Web. XML are more convenient.
4) removed a few restrictions.
5) Some examples are optimized


Changes to the listener for each version of the servlet are:
(1) servlet2.2 and jsp1.1
New Listener:httpsessionbindinglistener
New Event:httpsessionbindingevent
(2) servlet2.3 and jsp1.2
New Listener:servletcontextlistener,servletcontextattributelistener
, Httpsessionlistener,httpsessionactivationlistener,httpsessionattributelistener
New Event:servletcontextevent,servletcontextattributeevent,httpsessionevent
(3) servlet2.4 and jsp2.0
New Listener:servletrequestlistener,servletrequestattriburelistener
New Event:servletrequestevent,servletrequestattributeevent

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.