The Java Web maps the logical name to the servlet file

Source: Internet
Author: User

Ⅰ, request URL

Ⅱ, container search dd, find servlet-mapping

<?XML version= "1.0" encoding= "Iso-8859-1"?><Web-appxmlns= "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">    <servlet>        <Servlet-name>Ch3 Beer</Servlet-name>        <Servlet-class>Com.example.web.BeerSelect</Servlet-class>    </servlet>    <servlet-mapping>        <Servlet-name>Ch3 Beer</Servlet-name>       <url-pattern>/SelectBeer.do</url-pattern>    </servlet-mapping></Web-app>

Ⅲ, find the url-pattrern corresponding to the internal DD Servlet-name

    < servlet-mapping >        <servlet-name>ch3 beer</servlet-name>        < Url-pattern >/selectbeer.do</url-pattern>    </  Servlet-mapping>

Ⅳ, using Servlet-name to find the corresponding servlet

    <servlet>        <servlet-name>ch3 beer</servlet-name>        <Servlet-class>Com.example.web.BeerSelect</Servlet-class>    </servlet>    <servlet-mapping>        <Servlet-name>Ch3 Beer</Servlet-name>        <Url-pattern>/selectbeer.do</Url-pattern>    </servlet-mapping>

Ⅴ, container load class, and initialize servlet (if not initialized yet)

    < servlet >        < Servlet-name > Ch3 Beer</servlet-name>        <servlet-class> com.example.web.beerselect</servlet-class>    </servlet>

Ⅵ, container opens a new thread processing and passes the request (the service () method passed to the servlet)

How does the container handle the request?

Ⅶ, the container sends the response back to the customer

The Java Web maps the logical name to the servlet file

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.