Home > 类库下载 > java类库 > JavaWeb learning summary_Servlet development

JavaWeb learning summary_Servlet development

高洛峰
Release: 2016-12-02 16:25:53
Original
1937 people have browsed it

1. Introduction to Servlet

2. The running process of Servlet

The Servlet program is called by the Web server. After the web server receives the client's Servlet access request:

The WEB server first checks whether it has been loaded and created an instance of the Servlet object. If yes, go to step 4 directly, otherwise go to step 2.

Load and create the init() method of the Servlet instance object

Call the init() method of the Servlet instance object

Create an HttpServletRequest object used to encapsulate the HTTP request message and an HttpServletResponse object representing the Http corresponding message, and then call Servlet's service() method, and the request and response objects are passed in as parameters.

Before the Web application is stopped or restarted, the Servlet engine will uninstall the Servlet and call the Servlet's destroy() method

3. Servlet call graph

JavaWeb learning summary_Servlet development

4. Servlet access URL mapping configuration

Same Servlet Can be mapped to multiple URLs, that is, the setting value of the sub-element of multiple elements can be the registered name of the same Servlet

<servlet>
        <description></description>
        <display-name>ServletDemo1</display-name>
        <servlet-name>ServletDemo1</servlet-name>
        <servlet-class>com.atguigu.servlet.ServletDemo1</servlet-class>
    </servlet>
    
    <!-- 同一个servlet可以映射到多个url -->
    <servlet-mapping>
        <servlet-name>ServletDemo1</servlet-name>
        <url-pattern>/servletDemo1</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>ServletDemo1</servlet-name>
        <url-pattern>/1.html</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>ServletDemo1</servlet-name>
        <url-pattern>/2.htm</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>ServletDemo1</servlet-name>
        <url-pattern>/3.htm</url-pattern>
    </servlet-mapping>
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template