




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、蘇州大學文正學院本科生畢業(yè)設(shè)計(論文)外文文獻JSP Technology and ServletsJSP profileJSP (JavaServer Pages) is initiated by Sun Microsystems, Inc., with many companies to participate in the establishment of a dynamic
2、60;web page technical standards. JSP technology somewhat similar to ASP technology, it is in the traditional HTML web page document (*. htm, *. html) to insert the J
3、ava programming paragraph (Scriptlet) and JSP tag (tag), thus JSP documents (*. jsp). Using JSP development of the Web application is cross that can run on Linux, is
4、 also available for other operating systems.JSP technology to use the Java programming language prepared by the category of XML tags and scriptlets, to produce dynamic pa
5、ges package processing logic. Page also visit by tags and scriptlets exist in the services side of the resources of logic. JSP page logic and web page design an
6、d display separation, support reusable component-based design, Web-based application development is rapid and easy.Web server in the face of visits JSP page request, the first
7、;implementation of the procedures of, and then together with the results of the implementation of JSP documents in HTML code with the return to the customer. Insert
8、the Java programming operation of the database can be reoriented websites, in order to achieve the establishment of dynamic pages needed to function.JSP and Java Servlet,
9、;is in the implementation of the server, usually returned to the client is an HTML text, as long as the client browser will be able to visit.JSP 1.0 specificati
10、on of the final version is launched in September 1999, December has introduced 1.1 specifications. At present relatively new is JSP1.2 norms, JSP2.0 norms of the draft
11、60;has also been introduced.JSP pages from HTML code and Java code embedded in one of the components.JS script language synopsis JS is javascrip, Javascript is one kind
12、160;the script language which comes by the Netscape LiveScript development, the main purpose is to solve the server terminal language, for instance Perl, carry-over speed ques
13、tion. At that time served the end to need to carry on the confirmation to the data, because the network speed was quite slow, only then 28.8kbps, the confirmati
14、on step waste's time were too many. Therefore Netscape browser Navigator has joined Javascript, has provided the data confirmation basic function. The JavaScript official name&
15、#160;is “ECMAScript”. This standard by ECMA organization development and maintenance. ECMA262 is the official JavaScript standard. This standard based on JavaScript (Netscape) and JScri
16、pt (Microsoft). Netscape (Navigator 2.0) Brendan Eich has invented this language, started from 1996, already appeared in all Netscape and in the Microsoft browser. The ECMA262
17、 development began in 1996, in 1997 July, the ECMA general meeting has accepted its first edition. The script uses one specific descriptive language, rests on certain
18、0;form compilation to be possible the execution document, is also called as great or the batch run document. The script usually may transfer temporarily by the applicatio
19、n procedure and carry out. Each kind of script present widely is applied in the homepage design, because the script not only may reduce the homepage the scale a
20、nd raises the homepage browsing speed, moreover may enrich the homepage performance, like animation, sound and so on. Cites a most common example, when we click in t
21、he homepage the Email address can transfer Outlook Express or the Foxmail this kind of mail software automatically, is realizes through the script function. Also because
22、of script these characteristics, the human who harbors ulterior motives by some are often using. For example joins some destruction computer system's order in the script,&
23、#160;like this works as the user browsing homepage, once transfers this kind of script, will then cause the user the system to come under the attack. Therefore the
24、160;user should act according to visits homepage the trust degree selective security rank, specially regarding these itself content on the illegal homepage, do not permit the&
25、#160;use script easily. Through “the safe establishment” the dialog box, the choice “the script” under option each kind of establishment may with ease realize to script b
26、eing forbid and begins using. JSP and ServletsThe technology of JSP and Servlet is the most important technology which use Java technology to exploit request of server,
27、160;and it is also the standard which exploit business application .Java developers prefer to use it for a variety of reasons, one of which is already familiar with&
28、#160;the Java language for the development of this technology are easy to learn Java to the other is "a preparation, run everywhere" to bring the concept of
29、0;Web applications, To achieve a "one-prepared everywhere realized." And more importantly, if followed some of the principles of good design, it can be said of separ
30、ating and content to create high-quality, reusable, easy to maintain and modify the application. For example, if the document in HTML embedded Java code too much (script)
31、, will lead the developed application is extremely complex, difficult to read, it is not easy reuse, but also for future maintenance and modification will also cause
32、;difficulties. In fact, CSDN the JSP / Servlet forum, can often see some questions, the code is very long, can logic is not very clear, a large number of H
33、TML and Java code mixed together. This is the random development of the defects.Early dynamic pages mainly CGI (Common Gateway Interface, public Gateway Interface) technology,
34、;you can use different languages of the CGI programs, such as VB, C / C + + or Delphi, and so on. Though the technology of CGI is developed and powerf
35、ul, because of difficulties in programming, and low efficiency, modify complex shortcomings, it is gradually being replaced by the trend. Of all the new technology, JSP /
36、 Servlet with more efficient and easy to program, more powerful, more secure and has a good portability, they have been many people believe that the future is t
37、he most dynamic site of the future development of technology.Similar to CGI, Servlet support request / response model. When a customer submit a request to the server,
38、0;the server presented the request Servlet, Servlet responsible for handling requests and generate a response, and then gave the server, and then from the server sent to&
39、#160;the customer. And the CGI is different, Servlet not generate a new process, but with HTTP Server at the same process. It threads through the use of technology,&
40、#160;reduce the server costs. Servlet handling of the request process is this: When received from the client's request, calling service methods, the method of Servlet arri
41、val of the first judgement is what type of request (GET / POST / HEAD), then calls the appropriate treatment (DoGet / doPost / doHead) and generate a response.A
42、lthough such a complex, 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
43、0;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,&
44、#160;including the safety of the management, use JDBC access the database and crossplatform capability. Moreover, Servlet using thread, and can develop more efficient Web applicati
45、ons.JSP technology is a key J2EE technology, it at a higher level of abstraction of a Servlet. It allows conventional static and dynamic HTML content generated by co
46、mbining an HTML page looks like, but as a Servlet to run. There are many commercial application server support JSP technology, such as BEA WebLogic, IBM WebSphere, J
47、Run, 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
48、 HTML files can be placed, do not have to compile, do not have to pack, do not have to ClassPath settings, you can visit as ordinary Web It did visit,
49、 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
50、;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&
51、#160;a JSP engine Java source files, is actually a Servlet, and compiler, and then, like other Servlet, from Servlet engine to handle. Servlet engine of this type lo
52、ading, handling requests from customers, and the results returned to the customer.After another visit this page to the customer, as long as the paper there have been
53、;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,&
54、#160;translate, compile and load. In fact, this is the so-called "first person to punishment." Because when the first visit to the implementation of a series of
55、;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
56、0;request, the session, and the application. combining JSP with servlets lets you clearly separate the application logic from the presentation of the application; in other wor
57、ds, it lets you use the most appropriate component type for the roles of Model, View and Controller. Servlets, Filters, and ListenersA servlet is a Java class
58、that extends a server with functionality for processing a request and producing a response. It's implemented using the classes and interfaces defined by the Servlet API.
59、160;The API consists of two packages: the javax.servlet package contains classes and interfaces that are protocolindependent, while the javax.servlet.http package provides HTTP-specific exte
60、nsions and utility classes.What makes a servlet a servlet is that the class implements an interface named javax.servlet.Servlet, either directly or by extending one of the
61、0;support classes. This interface defines the methods used by the web container to manage and interact with the servlet. A servlet for processing HTTP requests typically exten
62、ds the javax.servlet.http.HttpServlet class. This class implements the Servlet interface and provides additional methods suitable for HTTP processing.Servlet LifecycleThe web container manages
63、60;all aspects of the servlet's lifecycle. It creates an instance of the servlet class when needed, passes requests to the instance for processing, and eventually removes&
64、#160;the instance. For an HttpServlet, the container calls the following methods at the appropriate times in the servlet lifecycle. Besides the doGet( ) and doPost( ) met
65、hods, there are methods corresponding to the other HTTP methods: doDelete( ), doHead( ), doOptions( ), doPut( ), and doTrace( ). Typically you don't implement these m
66、ethods; the HttpServlet class already takes care of HEAD, OPTIONS, and TRACE requests in a way that's suitable for most servlets, and the DELETE and PUT HTTP
67、60;methods are rarely used in a web application. It's important to realize that the container creates only one instance of each servlet. This means that the servlet
68、160;must be thread safe - able to handle multiple requests at the same time, each executing as a separate thread through the servlet code. Without getting lost in
69、60;details, you satisfy this requirement with regards to instance variables if you modify the referenced objects only in the init( ) and destroy( ) methods, and just
70、;read them in the request processing methods.Compiling and Installing a ServletTo compile a servlet, you must first ensure that you have the JAR file containing all Servl
71、et API classes in the CLASSPATH environment variable. The JAR file is distributed with all web containers. Tomcat includes it in a file called servlet.jar, located in
72、0;the common/lib directory. On a Windows platform, you include the JAR file in the CLASSPATH. Reading a Request One of the arguments passed to the doGet( ) and
73、doPost( ) methods is an object that implements the HttpServletRequest interface. This interface defines methods that provide access to a wealth of information about the reques
74、t. Generating a ResponseBesides the request object, the container passes an object that implements the HttpServletResponse interface as an argument to the doGet( ) and d
75、oPost( ) methods. This interface defines methods for getting a writer or stream for the response body. It also defines methods for setting the response status code a
76、nd headers. Using Filters and Listeners The servlet specification defines two component types beside servlets: filters and listeners. These two types were introduced in the Se
77、rvlet 2.3 specification, so if you're using a container that doesn't yet support this version of the specification, I'm afraid you're out of luck.FiltersA filter is
78、 a component that can intercept a request targeted for a servlet, JSP page, or static page, as well as the response before it's sent to the client. This
79、0;makes it easy to centralize tasks that apply to all requests, such as access control, logging, and charging for the content or the services offered by the applicat
80、ion. A filter has full access to the body and headers of the request and response, so it can also perform various transformations. One example is compressing the
81、0;response body if the Acceptlanguage request header indicates that the client can handle a compressed response. A filter can be applied to either a specific servlet or&
82、#160;to all requests matching a URL pattern, such as URLs starting with the same path elements or having the same extension.ListenersListeners allow your application to react&
83、#160;to certain events. Prior to Servlet 2.3, you could handle only session attribute binding events (triggered when an object was added or removed from a session). You
84、160;could do this by letting the object saved as a sessionattributimplement the HttpSessionBindingListener interface. With the new interfaces introduced in the 2.3 version of the&
85、#160;specification, you can create listeners for servlet context and session lifecycle events as well as session activation and passivation events (used by a container that te
86、mporarily saves session state to disk or migrates a session to another server). A newsession attribute event listener also makes it possible to deal with attribute bindin
87、g events for all sessions in one place, instead of placing individual listener objects in each session.The new types of listeners follow the standard Java event model.
88、60;In other words, a listener is a class that implements one or more of the listener interfaces. The interfaces define methods that correspond to events. The listener
89、0;class is registered with the container when the application starts, and the container then calls the event methods at the appropriate times.Initializing Shared Resources Using
90、60;a ListenerBeans like this typically need to be initialized before they can be used. For instance, they may need a reference to a database or some other external
91、160;data source and may create an initial information cache in memory to provide fast access even to the first request for data. You can include code for initializat
92、ion of the shared resources in the servlet and JSP pages that need them, but a more modular approach is to place all this code in one place and let th
93、e other parts of the application work on the assumption that the resources are already initialized and available. An application lifecycle listener is a perfect tool for&
94、#160;this type of resource initialization. This type of listener implements the javax.servlet.ServletContextListener interface, with methods called by the container when the application
95、0;starts and when it shuts down.Picking the Right Component Type for Each Task The Project Billboard application introduced is a fairly complex application. Half the pages
96、0;are pure controller and business logic processing, it accesses a database to authenticate users, and most pages require access control. In real life, it would likely co
97、ntain even more pages, for instance, pages for access to a shared document archive, time schedules, and a set of pages for administration. As the application evolves,
98、0;it may become hard to maintain as a pure JSP application. It's easy to forget to include the access control code in new pages. This is clearly an applicat
99、ion that can benefit from using a combination of JSP pages and the component types defined by the servlet specification for the MVC roles. Let's look at the
100、;main requirements and see how we can map them to appropriate component types:Database access should be abstracted, to avoid knowledge of a specific data schema or database engine in more than one part of the application: beans in the role of Model can be used to accom
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 爆破與安全試題及答案
- 保溫工考試試題及答案
- 安全師試題及答案
- 物聯(lián)網(wǎng)設(shè)備安全漏洞檢測與防護策略在智能交通信號控制系統(tǒng)中的實戰(zhàn)解析報告
- 2025年快時尚零售行業(yè)供應鏈優(yōu)化與變革分析報告
- 安全教育考試試題及答案
- 安全規(guī)程考試試題及答案
- 職業(yè)教育未來趨勢:2025年職業(yè)院校與企業(yè)深度合作研究報告
- 2025年醫(yī)院信息化建設(shè)關(guān)鍵環(huán)節(jié):電子病歷系統(tǒng)醫(yī)療信息化戰(zhàn)略規(guī)劃報告
- 大學生膳食營養(yǎng)與健康
- 能源經(jīng)營產(chǎn)品技術(shù)規(guī)范-三輪兩輪電動車鋰電池組技術(shù)規(guī)范V1.0
- 大學專業(yè)選擇演講課件
- 茂名酒店行業(yè)報告
- 富士康大過管理制度
- 一汽大眾質(zhì)量控制體系培訓手冊2
- 學校桌椅采購投標方案(技術(shù)標)
- 十典九章宣貫(終)
- 用人單位評價調(diào)查表
- 江蘇開放大學2023年秋《公共關(guān)系原理與實務050010》過程性考核作業(yè)三參考答案
- 2023年上海市普通高中學業(yè)水平合格性考試物理試(含答案解析)
- 10kV~500kV輸變電及配電工程質(zhì)量驗收與評定標準:06變電自動化工程
評論
0/150
提交評論