How the Servlet container handles the request resource path

Source: Internet
Author: User

First, what is the request resource path
The address format entered in the browser address bar is as follows:
Http://ip:port/appName/xx.html
Where appname/xx.html is the request resource path

Second, the Web server to the request path processing process
Enter http://ip:port/appName/xx.html in the browser address bar

    1. The browser establishes a connection to the Servlet container based on Ip,port, and then sends the request resource path appname/xx.html past to the container
    2. The container finds the folder according to the application name "/appname" and the container will default to a servlet, looking for all servlet configuration "" in the Web. xml file to see if there is a matching servlet.

Third, match the servlet rule
1. Exact match
By comparing the specific resource names in the request resource path to the "" in the Web. xml file, the corresponding resource is found and executed after the match is strictly equal
-such as: abc.html
-Although the application has abc.html this specific page, it will execute the url-pattern corresponding servlet instead of returning to the specific abc.html page.

2. Wildcard match

    • Use "*" to match 0 or more characters
    • such as:/*
    • Represents the input any different URL addresses are matched successfully
    • Http://ip:port/appName/abc.html Matching Success
    • Http://ip:port/appName/abc/def also matches the success

3. Suffix matching
-You cannot start with a slash, use "*." Any number of characters at the beginning
-For example: *.do will match all requests ending with ". Do"
-Http://ip:port/appName/abc.do Matching success
-Http://ip:port/appName/abc/abc.do also matches the success

4. Processing of a servlet without matching

    • If exact matches, wildcard matches, and suffix matches do not match successfully, the container looks for the appropriate file
    • Find the corresponding file and return
    • Returned 404 Not Found

Note: The highest priority is the exact match

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

How the Servlet container handles the request resource path

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.