【正文】
可以處理壓縮的應(yīng)答,那么過濾器就可以壓縮應(yīng)答的行為體。 生成應(yīng)答 除應(yīng)答對(duì)象之外,容器 還將實(shí)現(xiàn) HttpServletRequest接口的對(duì)象作為 icanshu傳遞給 doGet()和 doPost()方法。這意味著 servlet 必須是線程安全的 — 即,能夠同時(shí)處理多個(gè)請(qǐng)求,每個(gè)處理都通過 servlet 代碼作為單獨(dú)的線程來執(zhí)行。用于處理 HTTP 請(qǐng)求的 servlet 一般情況下都會(huì)擴(kuò)展 類。因?yàn)槭状卧L問的時(shí)候要執(zhí)行一 系列以上的過程,所以會(huì)耗費(fèi)一些時(shí)間;以后的訪問就不會(huì)這樣了。使用 JSP 比用 Servlet 更簡單。 Servlet處理請(qǐng)求的過程是這樣的:當(dāng)收到來自客戶端的請(qǐng)求后,調(diào)用 service 方法,該方法中 Servlet先判斷到來的請(qǐng)求是什么類型的( GET/POST/HEAD?),然后調(diào)用相應(yīng)的處理方法( doGet/doPost/doHead?)并生成響應(yīng)。這就是隨意開發(fā)的弊端。s easy to forget to include the access control code in new pages. This is clearly an application that can benefit from using a bination of JSP pages and the ponent types defined by the servlet specification for the MVC roles. Let39。 the HttpServlet class already takes care of HEAD, OPTIONS, and TRACE requests in a way that39。s request, calling service methods, the method of Servlet arrival of the first judgement is what type of request (GET / POST / HEAD…), then calls the appropriate treatment (DoGet / doPost / doHead…) and generate a response. Although such a plex, in fact, simply said to Servlet is a Java class. And the general category of the difference is that this type operating in a Servlet container, which can provide session management and targeted lifecycle management. So that when you use the Servlet, you can get all the benefits of the Java platform, including the safety of the management, use JDBC access the database and crossplatform capability. Moreover, Servlet using thread, and can develop more efficient Web applications. JSP technology is a key J2EE technology, it at a higher level of abstraction of a Servlet. 3 It allows conventional static and dynamic HTML content generated by bining an HTML page looks like, but as a Servlet to run. There are many mercial application server support JSP technology, such as BEA WebLogic, IBM WebSphere, JRun, and so on. JSP and Servlet use more than simple. If you have a JSP support for Web servers, and a JSP document, you can put it Fangdao any static HTML files can be placed, do not have to pile, do not have to pack, do not have to ClassPath settings, you can visit as ordinary Web It did visit, the server will automatically help you to do other work. JSP document looks like an ordinary static HTML document, but inside contains a number of Java code. It uses. Jsp the suffix, used to tell the server this document in need of special treatment. When we visit a JSP page, the document will first be translated into a JSP engine Java source files, is actually a Servlet, and piler, and then, like other Servlet, from Servlet engine to handle. Servlet engine of this type loading, handling requests from customers, and the results returned to the customer, as shown below: Figure 1: Calling the process of JSP pages 4 After another visit this page to the customer, as long as the paper there have been no changes, JSP engine has been loaded directly call the Servlet. If you have already been modified, it will be once again the implementation of the above process, translate, pile and load. In fact, this is the socalled first person to punishment. Because when the first visit to the implementation of a series of the above process, so will spend some time after such a visit would not. Java servlets offer a powerful API that provides access to all the information about the request, the session, and the application. bining JSP with servlets lets you clearly separate the application logic from the presentation of the application。re using a container that doesn39。s not formally defined in the servlet specification. 沈陽航空 航天大學(xué) 北方科技學(xué)院畢業(yè)設(shè)計(jì) (外文翻譯 ) 12 將 Servlet 和 JSP 組合使用 Servlet 和 JSP 技術(shù)是用 Java 開發(fā)服務(wù)器端應(yīng)用的主要技術(shù),是開發(fā)商務(wù)應(yīng)用表示端的標(biāo)準(zhǔn)。在所有的新技術(shù)中, JSP/Servlet具備更高效、更容易編程、功能更強(qiáng)、更安全和具有良好的可移植性,因而被許多人認(rèn)為是未來最有發(fā)展前途的動(dòng)態(tài)網(wǎng)站技術(shù)。因而當(dāng)你使用 Servlet的時(shí)候,你可以得到 Java平臺(tái)的所有好處,包括安全性管理 、使用JDBC訪問數(shù)據(jù)庫以及跨平臺(tái)的能力。它使用 .jsp的后綴,用來告訴服務(wù)器這個(gè)文件需要特殊的處理。 Servlet、過濾器和監(jiān)聽器 Servlet 是一種 Java 類,它使得服務(wù)器的功能可擴(kuò)展至處理請(qǐng)求和生成應(yīng)答。它根據(jù)需要?jiǎng)?chuàng)建 servlet 類的實(shí)例、將請(qǐng)求傳遞給實(shí)例進(jìn)行處理,最終刪除實(shí)例。該 JAR文件將隨所有的 Web容器一起發(fā)布。 使用過濾器和監(jiān)聽器 Servlet 規(guī)范 servlet 內(nèi)定義了兩種組件類型:過濾器和監(jiān)聽器。 Servlet ,只能處理會(huì)話屬性綁 定事件(在添加對(duì)象或從會(huì)話中刪除對(duì)象時(shí))。 使用監(jiān)聽器初始化共享資源 Bean 一般都有需要在使用之前進(jìn)行初始化。由于應(yīng)用程序在不斷地發(fā)展變化,因此可能變得很難作為純 JSP應(yīng)用程序來維護(hù)。 將 servlet、監(jiān)聽器和過濾器混合起來,就將 JSP頁面對(duì)復(fù)雜邏輯的需求降到了最低。 ? 在不修改代碼的情況下改變應(yīng)用程序頁面