Java Common Interface Rollup

Source: Internet
Author: User

Servlet Common Interface:

1, the servlet implementation Related:

(1) Servlet interface: Primarily defines the lifecycle method of the servlet, which defines the following methods:

L init (servletconfig config) is used to initialize the servlet

L Destroy () destroy Servlet

L Getservletinfo () Get information about the servlet

L Getservletconfig () obtain servlet configuration-related information

L Service (ServletRequest req, servletresponse Res) runs the application's logical entry point. ServletRequest represents the client's request information; Servletresponse represents the response to the client.

(2) Genericservlet abstract class: Provides a general implementation of the servlet (including the implementation of the servlet and ServletConfig two interfaces), An important object of a servletconfig type that the container passes through the Init method to the servlet is saved.

(3) HttpServlet abstract class: Provides a general implementation for the servlet that handles HTTP requests, primarily defining and implementing several service methods. The HttpServlet subclass must implement one of the following methods:

L doget ()

L DoPost ()

L DoPut ()

L Dodelete ()

L init () and Destroy ()

L Getservletinfo ()

2, servlet configuration Related:

(4) ServletConfig interface: Provides a servlet with a number of important objects and methods for using container services. The main methods are as follows:

L Getinitparameter (String name) returns the initialization parameters for a particular name.

L Getinitparameternames () returns the name of all initialization parameters

L Getservletcontext () returns a reference to the context object of the servlet.

3, Servlet context-Related:

(5) ServletContext interface: Is the context object of the servlet, which was created at server startup and provides the servlet with several important methods for using container services. It's commonly used methods:

L getattribute (String name) gets the property named name in ServletContext

L GetContext (String Uripath) Returns the context of the servlet for the given Uripath application

L removeattribute (String name) deletes a property with name

L setattribute (String Name,object object) sets a property in ServletContext, the name of the property, and the value is object.

4. Request and Response related

There are a number of interfaces and classes associated with requests and responses, mainly several:

(6) ServletRequest: Represents the request of the servlet. It's a high-level interface, and HttpServletRequest is its sub-interface.

(7) Servletresponse: Represents the response of the servlet. It's a high-level interface, and HttpServletResponse is its sub-interface.

(8) Servletinputstream:servlet input stream

(9) output stream of Servletoutputstream:servlet

(a) Servletrequestwrapper: the realization of ServletRequest

(one) Servletresponsewrapper: the realization of Servletresponse

(in) HttpServletRequest: represents HTTP request

(HttpServletResponse): Represents the response of HTTP

Implementation of (Httpservletrequestwrapper:httpservletrequest)

(a) Httpservletresponsewrapper:httpservletresponse implementation

5. Session Tracking

(HttpSession)

6. servlet Collaboration

(RequestDispatcher)

7, Filtration

(km) Filter

(Filterchain)

(Filterconfig)

Inheritance relationship: Genericservlet inherits the servlet and ServletConfig interfaces; HttpServlet inherits Genericservlet; The servlet we wrote Inherits HttpServlet.

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.