Java Servlet Specification_2.3

来源:互联网 发布:施乐m225z网络扫描 编辑:程序博客网 时间:2024/06/07 02:12

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

原创粉丝点击