Java Servlet Specification_2.3__Java

來源:互聯網
上載者:User

Overview 1.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 an architecture neutral
bytecode that can be 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).
servlet是一個被容器管理著的web組件,用來發布動態內容,servlet很小,java類被編譯成跨平台的位元組碼,
被web伺服器動態載入和執行。Servlets與被servlet容器實現了的web用戶端請求和響應的樣本進行互動。
這個就是基於HTTP的要求-回應模式。
 
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 be built into a host web server or installed as an add-on
component to a Web Server via that server’s native extension API. Servlet Containers can
also be built into or possibly installed into web-enabled Application Servers.
All servlet containers must support HTTP as a protocol for requests and responses, but may
also support additional request / response based protocols such 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 specification 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 (J2EE) environment, these restrictions should be placed using the permission
architecture defined by Java 2 Platform. For example, high end application servers may limit
certain action, such as the creation of a Thread object, to insure that other components of
the container are not negatively impacted.
servlet容器,結合web伺服器或者應用程式伺服器,提供請求和響應網路服務的集合。基於MIME解碼格式的請求和基於MIME格式的響應。一個servlet容器當然也包含和管理多個的servlet通過它們的生命週期。
一個servlet容器可以被構建到主機web伺服器或者作為組件安裝到web伺服器中做為伺服器的本地擴充API。Servelt容器也可以被構建或者安裝到支援Web的應用程式伺服器中。所有的servlet容器必須支援HTTP,用於請求和響應。但是也可以支援增強請求/響應基於協議比如HTTS,SSL。HTTP規範要求容器最低版本必須實現了HTTP/1.0,強烈建議容器實現HTTP/1.1的規範。
一個Servlet容器在一個servlet執行的環境裡面有些地方可能會受安全限制 ,在Java2平台或者j2ee 這個限制用於使用許可權認證被定義在java 2 平台比如,高端應用伺服器可能會限制某個動作,比如某個線程的執行個體,以確保對其它的組件或者容器沒有其它的負作用。

1.3 An Example
A client program, such as a web browser, accesses a web server and makes an HTTP request.
This request is processed by the web server and is handed off to the servlet container. The
servlet container determines which servlet to invoke based on 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 was programmed with and can generate data to send back
to the client. It sends this data back to the client via the response object.
Once the servlet is done with the request, the servlet container ensures that the response is
properly flushed and returns control back to the host web server.
一個用戶端程式,比如web瀏覽器,通過HTTP請求訪問web服務,這個請求被web伺服器處理然後遞給servlet容器,這個容器根據內部配置確定哪個servle處理這個請求。然後servlet會調用request和response對象來處理。servlet容器也可以當作同一個進程運行在同一台應用伺服器上,或者不同的進程在同一個主機上,或者不同主機上從web伺服器處理請求。 使用request對象找出哪個遠程在使用它,HTML表單程式裡的資料被當作request其中的一部分被發送,還包括其它關聯的資料,這個servlet執行程式中的任何邏輯然後產生資料發送給瀏覽器,以response對象的形式發送資料給瀏覽器用戶端,一旦這個servlet處理完畢這個請求,servlet容器確保這個response被重新整理,然後把控制權交還給主機伺服器。

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 that 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
J2EE specification describes additional requirements for servlet containers, and servlets that
are deployed into them, that are executing in a J2EE 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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.