Java Servlet API Description Document (2.1A) (1)

xiaoxiao2021-03-06  60

Java Servlet API Description Document (2.1A) (1)

Summary

A documentation about version 2.1 Java Servlet API (2002-08-29 13:26:40)

By Wing, Source:

LinuxAid

Translator's preface: Recently, when I organize the servlet information, I can't find a Chinese Java Servlet API in the Internet, and the Java Servlet API attached to the JSP book is not complete, and this Documentation 2.1A version has been finalized in November 1998. So I decided to translate a Chinese document (some of whom have been omitted), interested readers can be from http://java.sun.com/products/serve/2.1/servletspec-2.1 .zip download the original reading. Java Servlet API Description Document (2.1A Version) In November 1998 This is a documentation about version 2.1 Java Servlet API, as a supplement to this document, you can go to http://java.sun.com/ Products / Servlet / INDEX.html The following downloads the documentation in Javadoc format. Who needs to read this document describe the latest version version 2.1 of the Java Servlet API. Therefore, this book applies to the developers of servlets and servlet engines. The composition of the Java Servlet API is composed of two packages: one is a software package corresponding to HTTP, and the other is a universal package that does not correspond to HTTP. These two packages exist while the Java Servlet API can adapt to future other requests-responding protocols. This document and documents that have just mentioned Javadoc formats describe these two packages, and the documentation in Javadoc format also describes how you should use all methods in these two packages. For specification you may interested in these Internet norms, these specifications will directly affect the development and implementation of the Servlet API. You can find all of these RFC specifications mentioned below from http://info.internet.isi.edu/7c/in-notes/rfc/.cache. RFC 1738 Unified Resource Locator (URL) RFC 1808 Related Unified Resource Locator RFC 1945 Hypertext Transport Protocol - HTTP / 1.0 RFC 2045 Multi-Purpose Internet Mail Extensions (Multi-Used Internet Save Extension Protocol (MIME)) Part: Internet Information Body format RFC 2046 Multi-Use Internet Mail Extension (Multi-Used Internet Snap Extension Protocol (MIME)) Part II: Media Type RFC 2047 Multi-Use Internet Snap Protocol (MIME) (Multi-Use Internet Mail Extension) Part III: Information Title Extended for non-ASCII text RFC 2048 Multi-purpose Internet Mail Extensions (Multi-purpose Internet Snap Protocol (MIME)) Part 4: Register Step RFC 2049 Multi - Use Internet Mail Extensions (Multi-Use Internet Save Extension Protocol (MIME)) fifth Part: Consistency Standards and Example RFC 2068 Hypertext Transfer Protocol - HTTP / 1.1 RFC 2069 An Extension HTTP: Summary Access Identification RFC 2109 HTTP Status Management Matter RFC 2145 HTTP Release Number Usage and Explanation RFC 2324 Super Text Coffee Pot Control Protocol (HTCPCP / 1.0) The World Wide Web Association (http://www.w3.org) manages specification and execution of these protocols. About Java Servlets Javatm Servlets is a Java applet that is not subject to platform constraints, which can be used to expand the functionality of a web server through a variety of ways. You can understand the Applets on the Server, which is compiled into a zona code so that it can be dynamically loaded and efficiently expanded to extend the processing power of the host. Different parts of Servlets and Applets are that it does not run on a web browser or other graphical user interface.

The servlet is running in the web server through the servlet engine to perform a request and response, a typical example of the request, and a response is an HTTP protocol. A client program can be a web browser, or non-other programs that can connect to the Internet, which will access the web server and issue a request. This request is running the servlet engine on the web server and returns a response to servlet. The servlet forwards this response to the client via HTTP. In terms of function, servlet is a bit similar to CGI, NSAPI, but different from them is that servlet has platform independent. The Java Servlet Annual Servlet has the following progress: because it uses different process processing mode, it is faster than CGI. It uses the standard APIs supported by many web servers. It inherits all the advantages of Java, including easy upgrade, and platform-independent. It can call the functional modules of a large number of APIs provided by Java. This document illustrates the method of the class and interface of the Java Servlet API. For more information, see the API description below. The lifecycle of the servlet has a Java Servlet with a lifecycle. This lifecycle defines how a servlet is loaded and initialized, how to receive requests and make a response to requests, how to clean it from the service. The lifecycle of the servlet is defined by the interface of javax.servlet.servlet. All Java servlets will execute the javax.servlet.servlet interface directly or indirectly so that it can run in a servlet engine. The servlet engine is a Web server that is customized by the Java Servlet API. The Servlet engine provides network services that can understand the MIME request and provide a container running servlet. The Javax.Servlet.Servlet interface defines the method of a specific time in the lifecycle of the servlet and the specific order. The parsing of servlets and loads the servlet engine resolution and loads a servlet, which can occur when the engine is started, and a servlet is required to respond to requests, and at any time between this. The servlet engine uses the Java class load tool to load a servlet, and the servlet engine can load the servlet from a local file system, a remote file system, and the network. After servlet, the servlet engine loads servlet, the Servlet engine must initialize the servlet. In this process, you can read some fixed storage data, initialize the JDBC connection, and establish a connection to other resources. In the initialization process, the init () method of the Javax.serveT.Servlet interface provides the initialization information of the servlet. This way, servlet can configure it yourself. The init () method obtains a servletconfig. This object is executed in the servlet engine and allows servlets to be related parameters from it. This object allows the servlet to access the ServletContext object. After the servlet processing request servlet is initialized, it has been able to handle a request from the client, and each request from the client is described as a servletRequest object, and the Servlet response is described as a servletResponse object. When the client issues a request, the Servlet engine passes a servletRequest object and a servletResponse object, which is passed as a parameter into the service () method.

The servlet can also perform the servletRequest interface and servletResponse interface. The servletRequest interface allows servlets to use the requests issued by the client. The servlet can read the request information through the ServletInputStream object. The servletResponse interface allows the servlet to establish a response header and status code. By performing this interface, servlet has the right to use the ServletOutputStream class to return data to the client. Multi-threading and mapping In multi-threaded environments, the servlet must be able to handle many simultaneous requests. The exception is that this servlet executes a SingLethReadModel interface. If so, servlet can only process a request at the same time. The servlet responds to the client's request in accordance with the mapping of the Servlet engine. A mapping pair includes a servlet instance and a URL that returns data, for example: helloservlet with /hello/index.html. However, a mapping may be composed of a URL and a number of servlet instances, such as: a distributed servlet engine may run in more than one server, in which, there may be a servlet instance in each server to balance the process Load. As a servlet developer, you can't assume that a servlet has only one instance. Servlet's uninstall Servlet Engine does not have to ensure that a servlet is loaded at any time or at any time on service. The servlet engine can freely use or clear a servlet at any time. Therefore, we cannot rely on a class or instance to store important information. When the Servlet engine decides to uninstall a servlet (for example, this engine must allow the servlet to release the resources being used and store the relevant information. In order to complete the above work, the engine calls the servlet's Destroy () method. Before uninstalling a servlet, the Servlet engine must wait for all service () methods to complete or timeout (the servlet engine will define the timeout). When a servlet is uninstalled, the engine will not send any requests to the servlet. The engine must release the servlet and complete the use of the collection servlet mapping technology for the use of a servlet engine. You must have a lot of adaptability to how to map the client's request to servlet. This document does not specify how the mapping occurs. However, you must be able to freely use all of the following techniques: Map a servlet to a URL, for example, you can specify a special servlet it is only called from /FeedBack/index.html. Map all URLs starting with a specified directory name For example, you can map a servlet to / catalog, so requested from / catalog /, / catalog / garden and /catalog/HouseWares/index.html will be mapped to This servlet. But requests from / catalogtwo or /catalog.html are not mapped. Map a servlet to all URLs ending with a specific field, for example, you can map a request from all in in.thtml to a specific servlet. Map a servlet to a special URL / servlet / servlet_name. For example, if you have established a servlet called Listtributes, you can access this servlet by using / servlet / listattributes.

转载请注明原文地址:https://www.9cbs.com/read-112685.html

New Post(0)