Servlet規範 The Servlet Interface

來源:互聯網
上載者:User

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次翻譯。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.