Java Servlet Specification_2.3__java

Source: Internet
Author: User

Overview1.1 What is Servlet?
A servlet is a Web component, managed by a container, that generates dynamic content.
Servlets are small, platform independent Java classes compiled to a architecture neutral
Bytecode that can is loaded dynamically into and run by a Web server. Servlets interact with
Web clients via a request response paradigm implemented by the servlet container. This
Request-response model is based on the behavior of the hypertext Transfer Protocol (HTTP).
A servlet is a container-managed Web Component that publishes dynamic content, the servlet is small, and the Java class is compiled into a cross-platform byte code,
Dynamically loaded and executed by the Web server. Servlets interacts with an example of a Web client request and response that is implemented by the servlet container.
This is the HTTP-based request-response pattern.

1.2 What is a Servlet Container?
The servlet container, in conjunction with a Web server or application server, provides the
Network services over which requests and responses are set, decodes MIME based requests,
and formats MIME based responses. A servlet container also contains and manages Servlets
Through their lifecycle.
A servlet container can either is built into a host Web server or installed as a add-on
Component to a Web Server via that server ' s native extension API. Servlet containers can
Also be built to or possibly installed into web-enabled application Servers.
All servlet containers must support HTTP as a protocol for requests and responses but
Also support additional request/response based protocols as HTTPS (HTTP over SSL).
The minimum required version of the HTTP specification that a container must implement is
http/1.0. It is strongly suggested that containers implement the http/1.1 as
Well.
A servlet Container may place security restrictions on the environment that a servlet
Executes in. In a Java 2 Platform Standard Edition 1.2 (J2SE) or Java 2 Platform Enterprise
Edition 1.3 (Java EE) environment, these restrictions should are placed using the permission
Architecture defined by Java 2 Platform. For example, application servers may limit
Certain action, such as the creation of a Thread object, to insure which other components of
The container are not negatively impacted.
The servlet container, combined with a Web server or application server, provides a collection of request and response network services. Request based on MIME decoding format and response based on MIME format. A servlet container, of course, also contains and manages multiple servlet passes through their lifecycle.
A servlet container can be built into a host Web server or installed as a component into a Web server as a local extension API for the server. The Servelt container can also be built or installed into a Web-enabled application server. All servlet containers must support HTTP for requests and responses. However, you can also support enhanced request/response based protocols such as HTTS,SSL. The HTTP specification requires that the minimum version of the container must implement http/1.0, and it is strongly recommended that the container implement the http/1.1 specification.
A servlet container may be subject to security restrictions in a servlet-executed environment, in the JAVA2 platform or Java EE This restriction is used to use permission authentication is defined on 2 platforms for example, a high-end application server may restrict an action, such as an instance of a thread, To ensure that there is no other negative effect on other components or containers.

1.3 An Example
A client program, such as a Web browser, accesses a Web server and makes a HTTP request.
This request are processed by the Web server and is handed off to the servlet container. The
Servlet container determines which servlet to invoke based in its internal configuration and
Calls it with objects representing the request and response. The servlet container can run in
The same process as the host Web server, in a different process on the same host, or on a
Different host from the Web server for which it processes requests.
The servlet uses the request object to find out who the remote user is, what HTML form
Parameters may have been sent as part of this request, and other relevant data. The servlet
Can then perform whatever logic it is programmed and can generate data to send back
to the client. It sends this data on the client via the response object.
Once the servlet is do with the request, the Servlet container ensures the response is
Properly flushed and returns control is the host Web server.
A client program, such as a Web browser, accesses a Web service through an HTTP request, which is processed by the Web server and handed to the servlet container, which determines which Servle handles the request based on the internal configuration. The servlet then invokes the request and the response object for processing. The servlet container can also be run on the same application server as the same process, or the different processes on the same host, or on different hosts, process requests from the Web server. Using the Request object to find out which remote is using it, the data in the HTML form program is sent as part of the request, including other associated data, the servlet executes any logic in the program and then generates the data sent to the browser, Sends data to the browser client as a response object, and once the servlet has finished processing the request, the servlet container ensures that the response is refreshed and then returns control to the host server.

1.4 Comparing Servlets with other technologies
In functionality, Servlets lie somewhere between Common Gateway Interface (CGI) programs
and proprietary server extensions such as the Netscape server API (NSAPI) or Apache
Modules.
Servlets have the following advantages over other server extension mechanisms:
They are generally much faster than CGI scripts because a different process model is
Used.
They use a standard API this is supported by many Web servers.
They have all the advantages of the Java programming language, including ease of
Development and platform independence.
They can access the large set of APIs available for the Java platform.


1.5 Relationship to Java 2 Platform Enterprise Edition
The Servlet API v2.3 is a required API of the Java 2 Platform Enterprise Edition, v1.31. The
Java EE specification describes additional requirements for servlet containers, and Servlets
are deployed into them, which are executing in a Java-EE environment.
The Servlet Interface


Servlet Context


The Request


The Response


Servlet filtering


Sessions


Dispatching Requests


Web applications


Application Lifecycle Events


Mapping Requests to Servlets


Security


Deployment descriptor


Glossary


API Details


Javax.servlet


Javax.servlet.http

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.