Servlet规范 The Servlet Interface

CHAPTER 2 The Servlet Interface
第二章 Servlet Interface
The Servlet interface is the central abstraction of the Java Servlet API. All servlets
Servlet接口是Java Servlet API的核心抽象接口。
implement this interface either directly, or more commonly, by extending a class that
所有的servlet都是直接实现这个借口,或者更多的是继承一个已经实现了接口的类
implements the interface. The two classes in the Java Servlet API that implement the
在Java Servlet API 实现了Servlet接口的类是GenericServlet和HttpServlet。
Servlet interface are GenericServlet and HttpServlet. For most purposes,


Developers will extend HttpServlet to implement their servlets.
大多数情况下开发者继承HttpServlet来实现。
2.1 Request Handling Methods
请求处理的方法
The basic Servlet interface defines a service method for handling client requests.
Servlet接口定义了一个service方法来处理来自客户端的请求
This method is called for each request that the servlet container routes to an instance
servlet容器实例化一个servlet并为每个请求调用service方法
of a servlet.


The handling of concurrent requests to a Web application generally requires that the
Web应用通常需要处理并发请求,
Web Developer design servlets that can deal with multiple threads executing within
Web程序员设计的servlet需要在service方法中处理多线程处理
the service method at a particular time.


Generally the Web container handles concurrent requests to the same servlet by
通常的Web容器处理并发请求的方法是用不同的线程执行servlet的service方法
concurrent execution of the service method on different threads.


2.1.1 HTTP Specific Request Handling Methods
HTTP指定的处理请求方法
The HttpServlet abstract subclass adds additional methods beyond the basic
HttpServlet是一个抽象类相对于接口Servlet增加了additional方法,
Servlet interface that are automatically called by the service method in the
它由HttpServlet类的service方法自动调用,用来处理HTTP-based请求
HttpServlet class to aid in processing HTTP-based requests. These methods are:


■ doGet for handling HTTP GET requests
doGet用来处理HTTP的GET请求
■ doPost for handling HTTP POST requests
doPost用来处理HTTP的POST请求
■ doPut for handling HTTP PUT requests
doPut 用来处理HTTP的PUT 请求
■ doDelete for handling HTTP DELETE requests
doDelete 用来处理HTTP的DELETE 请求
■ doHead for handling HTTP HEAD requests
doHead 用来处理HTTP的HEAD 请求
■ doOptions for handling HTTP OPTIONS requests
doOptions 用来处理HTTP的OPTIONS 请求
■ doTrace for handling HTTP TRACE requests
doTrace 用来处理HTTP的TRACE 请求
Typically when developing HTTP-based servlets, a Servlet Developer will only
当开发典型的HTTP-based servlet时候,Servlet开发人员不仅仅
concern himself with the doGet and doPost methods. The other methods are
关心doGet和doPost方法,
considered to be methods for use by programmers very familiar with HTTP
的其他方法被認為是非常熟悉HTTP編程的程序員使用的方法
programming.


2.1.2 Additional Methods
其他的方法(我感觉没什么用处)
The doPut and doDelete methods allow Servlet Developers to support HTTP/1.1
doPut和doDelete方法允许Servlet程序员支持HTTP/1.1客户端的功能
clients that employ these features. The doHead method in HttpServlet is a
HttpServlet中的doHead方法是特殊的doGet方法
specialized form of the doGet method that returns only the headers produced by the
仅仅返回header(不知道怎么翻译了)。
doGet method. The doOptions method responds with which HTTP methods are
servlet同样支持HTTP方法中的doOptions方法
supported by the servlet. The doTrace method generates a response containing all
doTrace方法生成一个响应包括所有的请求头发送来的TRACE请求
instances of the headers sent in the TRACE request.


2.1.3 Conditional GET Support
条件GET支持(实在不知道这个conditional是什么意思)
The HttpServlet interface defines the getLastModified method to support
HttpServlet接口定义了getLastModified方法来支持有条件的GET操作
conditional GET operations. A conditional GET operation requests a resource be sent
一个有条件的GET操作来请求一个资源,
only if it has been modified since a specified time. In appropriate situations,
而只有他从指定的时间被修改后才被发送
implementation of this method may aid efficient utilization of network resources.

在适当的情况下此方法的实现,可以帮助有效地利用网络资源。


第二章实在有一些长,所以第二章分3次翻译。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值