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

JavaWeb learning summary_Servlet development

Dec 02, 2016 pm 04:25 PM
javaweb

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


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1659
14
PHP Tutorial
1258
29
C# Tutorial
1232
24