The role of Web. XML in JSP projects

Source: Internet
Author: User

The Web. xml file under the Web-inf path (and must be located on that path) for each of the websites is referred to as the configuration descriptor.

For Java Web Apps, Web-inf is a special folder, and the Web container contains the contents of that folder, and the client browser cannot access anything under the Web-inf path.

Before the servlet2.5 specification, most of the components of the Java Web were configured for management through the XML. config file.

Starting with servlet3.0, you can also configure the administration Web Component with annotations, so the. xml file can become more concise.

The contents of Web. XML can be configured:

1. Configure JSP

2. Configuring and Managing Servlets

3. Configuration and Management Listener

4. Configuring and Managing the Filter

5. Configure Tag Library

6. Configure JSP Properties

In addition, Web. XML is also responsible for configuring and managing the following common content.

1. Configure and manage JAAS authorization authentication

2. Configuring and Managing resource references

3. Web Application Home

The root element of the Web. xml file is the <web-app .../> element, which adds the following properties to the SERVLET3.0 specification:

Metadata-complete: This property accepts a value of TRUE or false two properties. When True, the Web app will not load the Web components of the annotation configuration (such as Servlets, Filter, Listener, etc.)

How to configure the homepage:

<welcome-file-list>    <welcome-file>index.html</welcome-file>    <welcome-file> Index.htm</welcome-file>    <welcome-file>index.jsp</welcome-file></welcome-file-list >

  

The above configuration specifies that the first page of the Web application is index.html, index.htm, index.jsp.

If index.html does not exist, then index.htm do the homepage, and so on.

The specific contents are as follows:

<?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_4_0.xsd "  version=" 4.0 "  metadata-complete=" true ">< welcome-file-list>  <welcome-file>index.html</welcome-file>  <welcome-file> Index.htm</welcome-file>  <welcome-file>index.jsp</welcome-file></welcome-file-list ></web-app>

  

The role of Web. XML in JSP projects

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.