How Tomcat work Porter Chapter 11:standardwrapper

Source: Internet
Author: User

There are four types of container,engine,host,context,wrapper in Tomcat 4 and 5, and the simplecontext,simplewrapper that you have written has been briefly introduced. This chapter is about the Standardwrapper of Catalina.

The first wrapper is to represent a servlet, so the role of wrapper is to load the servlet class, the servlet information, and the Fiter to the servlet, as well as the fiter load, fiter.

1.servlet can inherit the Javax.servlet.SingleThreadModel (STM) interface

This ensures that a servlet instance will only appear in one thread.

However, there is no guarantee of thread safety, and if a global variable is used in a servlet, there will be an issue with thread execution errors.

This is achieved through the servlet pool.

If the Javax.servlet.SingleThreadModel interface is not inherited, it is returned directly if the servlet instance already exists.

2.servlet of loading

First call the Init method, passing an instance of Javax.servlet.ServletConfig. Call the Load method again

Because Catalina supports the loading of JSP classes, it checks whether the requested page is JSP, and if so, gets the wrapper that loads the JSP from the parent container, which is the context, and then gets the class name of the Servlet class that is used to load the JSP.

Loading the servlet triggers some event listener functions.

3.ServletConfig

In addition to inheriting the Wrapper interface interface, Standardwrapper also inherits the Javax.servlet.ServletConfig interface.

  

Public publicPublic publicvoid     Public publicPublic public 

4.StandardWrapperValve

Responsible for executing the servlet filter, and executing the service method.

Creates a filter, created by the information of an instance of the Filterdef class, and Applicationfilterconfig class is also created by an instance of the Filterdef class

Applicationfilterchain to perform various filter

How Tomcat work Porter Chapter 11:standardwrapper

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.