版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、<p><b> 附錄A </b></p><p> JSP Technology Conspectus And Specialties</p><p> The JSP (Java Server mix) technology is used by the Sun microsystem issued by the company to develo
2、p dynamic Web application technology. With its easy, cross-platform, in many dynamic Web application programming languages, in a short span of a few years, has formed a complete set of standards, and widely used in elect
3、ronic commerce, etc. In China, the JSP now also got more extensive attention, get a good development, more and more dynamic website to JSP technology. The related technologies of JS</p><p> The JSP a simple
4、 technology can quickly and with the method of generating Web pages. Use the JSP technology Web page can be easily display dynamic content. The JSP technology are designed to make the construction based on Web applicatio
5、ns easier and efficient, and these applications and various Web server, application server, the browser and development tools work together.</p><p> The JSP technology isn't the only dynamic web technol
6、ogy, also not the first one, in the JSP technology existed before the emergence of several excellent dynamic web technology, such as CGI, ASP, etc. With the introduction of these technologies under dynamic web technology
7、, the development and the JSP. Technical</p><p> JSP the development background and development history</p><p> In web brief history, from a world wide web that most of the network information
8、 static on stock transactions evolution to acquisition of an operation and infrastructure. In a variety of applications, may be used for based on Web client, look no restrictions.</p><p> Based on the brows
9、er client applications than traditional based on client/server applications has several advantages. These benefits include almost no limit client access and extremely simplified application deployment and management (to
10、update an application, management personnel only need to change the program on a server, not thousands of installation in client applications). So, the software industry is rapidly to build on the client browser multi-la
11、yer application.</p><p> The rapid growth of exquisite based Web application requirements development of technical improvements. Static HTML to show relatively static content is right choice, The new challe
12、nge is to create the interaction based on Web applications, in these procedures, the content of a Web page is based on the user's request or the state of the system, and are not predefined characters.</p><
13、p> For the problem of an early solution is to use a CGI - BIN interface. Developers write to interface with the relevant procedures and separate based on Web applications, the latter through the Web server to invoke
14、the former. This plan has serious problem -- each new extensible CGI requirements in a new process on the server. If multiple concurrent users access to this procedure, these processes will use the Web server of all avai
15、lable resources, and the performance of the system will be reduced </p><p> Some Web server providers have to provide for their server by plugins "and" the API to simplify the Web application deve
16、lopment. These solutions are associated with certain Web server, cannot solve the span multiple suppliers solutions. For example, Microsoft's Active Server mix (ASP) technology in the Web page to create dynamic conte
17、nt more easily, but also can work in Microsoft on Personal Web Server and IIS.</p><p> There are other solutions, but cannot make an ordinary page designers can easily master. For example, such as the Servl
18、et Java technologies can use Java language interaction application server code easier. Developers to write such Servlet to receive signals from the Web browser to generate an HTTP request, a dynamic response (may be inqu
19、ires the database to finish the request), then send contain HTML or XML documents to the response of the browser.</p><p> ? note: one is based on a Java Servlet Java technical operation in the server progra
20、m (with different, the latter operating in the Applet browser end). In this book the Servlet chapter 4.</p><p> Using this method, the entire page must have made in Java Servlet. If developers or Web manage
21、rs want to adjust page, you'll have to edit and recompile the Servlet Java, even in logic has been able to run. Using this method, the dynamic content with the application of the page still need to develop skills.<
22、;/p><p> Obviously, what is needed is a industry to create dynamic content within the scope of the pages of the solution. This program will solve the current scheme are limited. As follows:</p><p>
23、; ? can on any Web server or applications.</p><p> ? will application page displays and separation.</p><p> ? can rapidly developing and testing.</p><p> ? simplify the interact
24、ive development based on Web application process.</p><p> The JSP technology is designed to meet such requirements. The JSP specification is a Web server, application server, trading system and develop exte
25、nsive cooperation between the tool suppliers. From this standard to develop the existing integration and balance of Java programming environment (for example, Java Servlet and JavaBeans) support techniques and tools. The
26、 result is a kind of new and developing method based on Web applications, using component-based application logic page designers wit</p><p> Overall Semantics of a JSP Page</p><p> A JSP page
27、implementation class defines a _jspService() method mapping from the request to the response object. Some details of this transformation are specific to the scripting language used (see Chapter JSP.9, “Scripting”). Most
28、details are not language specific and are described in this chapter.</p><p> The content of a JSP page is devoted largely to describing the data that is written into the output stream of the response. (The
29、JSP container usually sends this data back to the client.) The description is based on a JspWriter object that is exposed through the implicit object out (see Section JSP.1.8.3, “Implicit Objects”). Its value varies:<
30、/p><p> Initially, out is a new JspWriter object. This object may be different from the stream object returned from response.getWriter(), and may be considered to be interposed on the latter in order to implem
31、ent buffering (see Section JSP.1.10.1, “The page Directive”). This is the initial out object. JSP page authors are prohibited from writing directly to either the PrintWriter or OutputStream associated with the ServletRes
32、ponse.</p><p> The JSP container should not invoke response.getWriter() until the time when the first portion of the content is to be sent to the client. This enables a number of uses of JSP, including usin
33、g JSP as a language to “glue” actions that deliver binary content, or reliably forwarding to a servlet, or change dynamically the content type of the response before generating content. See Chapter JSP.4, “Internationali
34、zation Issues”.</p><p> Within the body of some actions, out may be temporarily re-assigned to a different (nested) instance of a JspWriter object. Whether this is the case depends on the details of the act
35、ion’s semantics. Typically the content of these temporary streams is appended to the stream previously referred to by out, and out is subsequently re-assigned to refer to the previous (nesting) stream. Such nested stream
36、s are always buffered, and require explicit flushing to a nesting stream or their contents will be</p><p> If the initial out JspWriter object is buffered, then depending upon the value of the autoFlush att
37、ribute of the page directive, the content of that buffer will either be automatically flushed out to the ServletResponse output stream to obviate overflow, or an exception shall be thrown to signal buffer overflow. If th
38、e initial out JspWriter is unbuffered, then content written to it will be passed directly through to the ServletResponse output stream.</p><p> A JSP page can also describe what should happen when some spec
39、ific events occur. In JSP 2.1, the only events that can be described are the initialization and the destruction of the page. These events are described using “well-known method names” in declaration elements..</p>
40、<p> JavaScript is used for the first kind is browser, the dynamic general purpose of client scripting language. Netscape first proposed in 1995, but its JavaScript LiveScript called. Then quickly Netscape LiveScr
41、ipt renamed JavaScript, Java developers with them from the same issued a statement. A statement Java and JavaScript will complement each other, but they are different, so the technology of the many dismissed the misunder
42、standing of the two technologies.</p><p> JavaScript to create user interface control provides a scripting language. In fact, in the browser into the JavaScript code logic. It can support such effect: when
43、the cursor on the Web page of a mobile user input validation or transform image.</p><p> Microsoft also write out their JavaScript version and the JScript called. Microsoft and Netscape support JavaScript a
44、nd JScript around a core characteristics and European Manufacturers is.md by (ECMA) standards organization, the control standard of scripting language. ECMA its scripting language ECMAScript named.</p><p>
45、Servlets and JSPs often include fragments of information that are common to an organization, such as logos, copyrights, trademarks, or navigation bars. The web application uses the include mechanisms to import the inform
46、ation wherever it is needed, since it is easier to change content in one place then to maintain it in every piece of code where it is used. Some of this information is static and either never or rarely changes, such as a
47、n organization's logo. In other cases, the information is mo</p><p> You want to include a resource that does not change very much (such as a page fragment that represents a header or footer) in a JSP.
48、Use the include directive in the including JSP page, and give the included JSP segment a .jspf extension.</p><p> You want to include content in a JSP each time it receives a request, rather than when the J
49、SP is converted to a servlet. Use the jsp:include standard action.</p><p> You want to include a file dynamically in a JSP, based on a value derived from a configuration file. Use the jsp:include standard a
50、ction. Provide the value in an external properties file or as a configuration parameter in the deployment descriptor.</p><p> You want to include a fragment of an XML file inside of a JSP document, or inclu
51、de a JSP page in XML syntax. Use the jsp:include standard action for the includes that you want to occur with each request of the JSP. Use the jsp:directive.include element if the include action should occur during the t
52、ranslation phase.</p><p> You want to include a JSP segment from outside the including file's context. Use the c:import</p><p> The operation principle and the advantages of JSP tags</p
53、><p> In this section of the operating principle of simple introduction JSP and strengths.</p><p> For the first time in a JSP documents requested by the engine, JSP Servlet is transformed into a
54、 document JSP. This engine is itself a Servlet. The operating process of the JSP shown below:</p><p> (1) the JSP engine put the JSP files converting a Java source files (Servlet), if you find the files hav
55、e any grammar mistake JSP, conversion process will interrupt, and to the server and client output error messages.</p><p> (2) if converted, with the engine JSP javac Java source file compiler into a corresp
56、onding scale-up files.</p><p> (3) to create a the Servlet (JSP page), the transformation of the Servlet jspInit () method was executed, jspInit () method in the life cycle of Servlet executed only once.<
57、;/p><p> (4) jspService () method invocation to the client requests. For each request, JSP engine to create a new thread for processing the request. If you have multiple clients and request the JSP files, JSP
58、engine will create multiple threads. Each client requests a thread. To execute multi-thread can greatly reduce the requirement of system resources, improving the concurrency value and response time. But also should notic
59、e the multi-thread programming, due to the limited Servlet always in response to</p><p> (5) if the file has been modified. The JSP, server will be set according to the document to decide whether to recompi
60、le, if need to recompile, will replace the Servlet compile the memory and continue the process.</p><p> (6) although the JSP efficiency is high, but at first when the need to convert and compile and some sl
61、ight delay. In addition, if at any time due to reasons of system resources, JSP engine will in some way of uncertain Servlet will remove from memory. When this happens jspDestroy () method was first call.</p><
62、p> (7) and then Servlet examples were marked with "add" garbage collection. But in jspInit () some initialization work, if establish connection with database, or to establish a network connection, from a co
63、nfiguration file take some parameters, such as, in jspDestory () release of the corresponding resources.</p><p> Based on a Java language has many other techniques JSP page dynamic characteristics, technica
64、l have embodied in the following aspects:</p><p> One simplicity and effectiveness</p><p> The JSP dynamic web pages with the compilation of the static HTML pages of writing is very similar. J
65、ust in the original HTML page add JSP tags, or some of the proprietary scripting (this is not necessary). So, a familiar with HTML page write design personnel may be easily performed JSP page development. And the develop
66、ers can not only, and write script by JSP tags used exclusively others have written parts to realize dynamic pages. So, an unfamiliar with the web developers scripting language, c</p><p> Tow the independen
67、ce of the program</p><p> The JSP are part of the family of the API Java, it has the general characteristics of the cross-platform Java program. In other words, is to have the procedure, namely the independ
68、ence of the platform, 6 Write bided anywhere! .</p><p> Three procedures compatibility</p><p> The dynamic content can various JSP form, so it can show for all kinds of customers, namely from
69、using HTML/DHTML browser to use various handheld wireless equipment WML (for example, mobile phones and pdas), personal digital equipment to use XML applications, all can use B2B JSP dynamic pages.</p><p>
70、Four program reusability</p><p> In the JSP page can not directly, but embedded scripting dynamic interaction will be cited as a component part. So, once such a component to write, it can be repeated severa
71、l procedures, the program of the reusability. Now, a lot of standard JavaBeans library is a good example.</p><p><b> 附錄B</b></p><p> JSP技術(shù)簡(jiǎn)介及特點(diǎn)</p><p> JSP(Java Serve
72、r Pages)技術(shù)是由Sun公司發(fā)布的用于開(kāi)發(fā)動(dòng)態(tài)Web應(yīng)用的一項(xiàng)技術(shù)。它以其簡(jiǎn)單易學(xué)、跨平臺(tái)的特性,在眾多動(dòng)態(tài)Web應(yīng)用程序設(shè)計(jì)語(yǔ)言中異軍突起,在短短幾年中已經(jīng)形成了一套完整的規(guī)范,并廣泛地應(yīng)用于電子商務(wù)等各個(gè)領(lǐng)域中。在國(guó)內(nèi),JSP現(xiàn)在也得到了比較廣泛的重視,得到了很好的發(fā)展,越來(lái)越多的動(dòng)態(tài)網(wǎng)站開(kāi)始采用JSP技術(shù)。下面就對(duì)JSP及其相關(guān)技術(shù)進(jìn)行簡(jiǎn)單的介紹。JSP技術(shù)可以以一種簡(jiǎn)捷而快速的方法生成Web頁(yè)面。使用JSP技術(shù)的Web頁(yè)面
73、可以很容易地顯示動(dòng)態(tài)內(nèi)容。JSP技術(shù)的設(shè)計(jì)目的是使得構(gòu)造基于Web的應(yīng)用程序更加容易和快捷,而這些應(yīng)用程序能夠與各種Web服務(wù)器、應(yīng)用服務(wù)器、瀏覽器和開(kāi)發(fā)工具共同工作。</p><p> JSP技術(shù)不是惟一的動(dòng)態(tài)網(wǎng)頁(yè)技術(shù),也不是第一個(gè),在JSP技術(shù)出現(xiàn)之前就已經(jīng)存在幾種優(yōu)秀的動(dòng)態(tài)網(wǎng)頁(yè)技術(shù),如CGI、ASP等。下面結(jié)合這些技術(shù)的介紹,講述動(dòng)態(tài)網(wǎng)頁(yè)技術(shù)的發(fā)展和JSP技術(shù)的誕生。</p><p&g
74、t; JSP的開(kāi)發(fā)背景及發(fā)展歷史</p><p> 在萬(wàn)維網(wǎng)短暫的歷史中,萬(wàn)維網(wǎng)已經(jīng)從一個(gè)大部分顯示靜態(tài)信息的網(wǎng)絡(luò)演化到對(duì)股票進(jìn)行交易和進(jìn)行購(gòu)書(shū)操作的一個(gè)基礎(chǔ)設(shè)施。在各種各樣的應(yīng)用程序中,對(duì)于可能使用的基于Web的客戶端,看上去沒(méi)有任何限制。</p><p> 基于瀏覽器客戶端的應(yīng)用程序比傳統(tǒng)的基于客戶機(jī)/服務(wù)器的應(yīng)用程序有幾個(gè)好處。這些好處包括幾乎沒(méi)有限制的客戶端訪問(wèn)和極其簡(jiǎn)化的應(yīng)
75、用程序部署和管理(要更新一個(gè)應(yīng)用程序,管理人員只需要更改一個(gè)基于服務(wù)器的程序,而不是成千上萬(wàn)的安裝在客戶端的應(yīng)用程序)。這樣,軟件工業(yè)正迅速地向建造基于瀏覽器客戶端的多層次應(yīng)用程序邁進(jìn)。</p><p> 這些快速增長(zhǎng)的精巧的基于Web的應(yīng)用程序要求開(kāi)發(fā)技術(shù)上的改進(jìn)。靜態(tài)HTML對(duì)于顯示相對(duì)靜態(tài)的內(nèi)容是不錯(cuò)的選擇;新的挑戰(zhàn)在于創(chuàng)建交互的基于Web的應(yīng)用程序,在這些程序中,頁(yè)面的內(nèi)容是基于用戶的請(qǐng)求或者系統(tǒng)的狀態(tài)
76、,而不是預(yù)先定義的文字。</p><p> 對(duì)于這個(gè)問(wèn)題的一個(gè)早期解決方案是使用CGI-BIN接口。開(kāi)發(fā)人員編寫(xiě)與接口相關(guān)的單獨(dú)的程序,以及基于Web的應(yīng)用程序,后者通過(guò)Web服務(wù)器來(lái)調(diào)用前者。這個(gè)方案有著嚴(yán)重的擴(kuò)展性問(wèn)題——每個(gè)新的CGI要求在服務(wù)器上新增一個(gè)進(jìn)程。如果多個(gè)用戶并發(fā)地訪問(wèn)該程序,這些進(jìn)程將消耗該Web服務(wù)器所有的可用資源,并且系統(tǒng)性能會(huì)降低到極其低下的地步。</p><p&
77、gt; 某些Web服務(wù)器供應(yīng)商已經(jīng)嘗試通過(guò)為他們的服務(wù)器提供“插件”和API來(lái)簡(jiǎn)化Web應(yīng)用程序的開(kāi)發(fā)。這些解決方案是與特定的Web服務(wù)器相關(guān)的,不能解決跨多個(gè)供應(yīng)商的解決方案的問(wèn)題。例如,微軟的Active Server Pages(ASP)技術(shù)使得在Web頁(yè)面上創(chuàng)建動(dòng)態(tài)內(nèi)容更加容易,但也只能工作在微軟的IIS和Personal Web Server上。</p><p> 還存在其他的解決方案,但都不能使一
78、個(gè)普通的頁(yè)面設(shè)計(jì)者能夠輕易地掌握。例如,像Java Servlet這樣的技術(shù)就可以使得用Java語(yǔ)言編寫(xiě)交互的應(yīng)用程序的服務(wù)器端的代碼變得容易。開(kāi)發(fā)人員能夠編寫(xiě)出這樣的Servlet,以接收來(lái)自Web瀏覽器的HTTP請(qǐng)求,動(dòng)態(tài)地生成響應(yīng)(可能要查詢(xún)數(shù)據(jù)庫(kù)來(lái)完成這項(xiàng)請(qǐng)求),然后發(fā)送包含HTML或XML文檔的響應(yīng)到瀏覽器。</p><p> ?注意:一個(gè)Java Servlet就是一個(gè)基于Java技術(shù)的運(yùn)行在服務(wù)器
79、端的程序(與Applet不同,后者運(yùn)行在瀏覽器端)。Servlet會(huì)在本書(shū)第4章介紹。</p><p> 采用這種方法,整個(gè)網(wǎng)頁(yè)必須都在Java Servlet中制作。如果開(kāi)發(fā)人員或者Web管理人員想要調(diào)整頁(yè)面顯示,就不得不編輯并重新編譯該Java Servlet,即使在邏輯上已經(jīng)能夠運(yùn)行了。采用這種方法,生成帶有動(dòng)態(tài)內(nèi)容的頁(yè)面仍然需要應(yīng)用程序的開(kāi)發(fā)技巧。</p><p> 很顯然,目
80、前所需要的是一個(gè)業(yè)界范圍內(nèi)的創(chuàng)建動(dòng)態(tài)內(nèi)容頁(yè)面的解決方案。這個(gè)方案將解決當(dāng)前方案所受到的限制。如下:</p><p> ?能夠在任何Web或應(yīng)用程序服務(wù)器上運(yùn)行。</p><p> ?將應(yīng)用程序邏輯和頁(yè)面顯示分離。</p><p> ?能夠快速地開(kāi)發(fā)和測(cè)試。</p><p> ?簡(jiǎn)化開(kāi)發(fā)基于Web的交互式應(yīng)用程序的過(guò)程。<
81、/p><p> JSP技術(shù)就是被設(shè)計(jì)用來(lái)滿足這樣的要求的。JSP規(guī)范是Web服務(wù)器、應(yīng)用服務(wù)器、交易系統(tǒng)以及開(kāi)發(fā)工具供應(yīng)商間廣泛合作的結(jié)果。Sun開(kāi)發(fā)出這個(gè)規(guī)范來(lái)整合和平衡已經(jīng)存在的對(duì)Java編程環(huán)境(例如,Java Servlet和JavaBeans)進(jìn)行支持的技術(shù)和工具。其結(jié)果是產(chǎn)生了一種新的、開(kāi)發(fā)基于Web應(yīng)用程序的方法,給予使用基于組件應(yīng)用邏輯的頁(yè)面設(shè)計(jì)者以強(qiáng)大的功能。</p><p&g
82、t;<b> JSP頁(yè)整體語(yǔ)義</b></p><p> JSP頁(yè)實(shí)施類(lèi)定義一個(gè)_ jspService() 方法映射反應(yīng)對(duì)象的請(qǐng)求。這些變革細(xì)節(jié)是具體用于腳本語(yǔ)言(參見(jiàn)Chapter JSP.9, “Scripting”)。多數(shù)細(xì)節(jié)不是具體語(yǔ)言,這些細(xì)節(jié)在這個(gè)章節(jié)里描述。</p><p> JSP頁(yè)的內(nèi)容主要致力于描述被寫(xiě)入反應(yīng)的輸出流的數(shù)據(jù)(JSP容器通常傳
83、送返回給客戶的數(shù)據(jù)。)描述是根據(jù)JspWriter對(duì)象它通過(guò)隱含對(duì)象暴露。(參見(jiàn)JSP.1.8.3, “Implicit Objects”)。</p><p><b> 值的變化:</b></p><p> ?首先, 定義一個(gè)JspWriter 對(duì)象,這個(gè)對(duì)象不同于response.getWriter()返回對(duì)象。</p><p> 并
84、且為了實(shí)施中間轉(zhuǎn)換,可以認(rèn)為是插入到buffering。這是最初外在對(duì)象。JSP 頁(yè)作者對(duì)于PrintWriter 或OutputStream 相關(guān)的ServletResponse被禁止寫(xiě)直接寫(xiě)入。</p><p> ?JSP容器不響應(yīng)response.getWriter()直到第一部份內(nèi)容送到客戶。JSP對(duì)“glue”動(dòng)作是一種語(yǔ)言,它是二進(jìn)制?;蛴趕ervlet相關(guān), 或在引起內(nèi)容之前改變反應(yīng)類(lèi)型內(nèi)容。參
85、照J(rèn)SP.4,“Internationalization Issues”. </p><p> ?在一些動(dòng)作主體中,輸出不同于JspWriter對(duì)象實(shí)例的再分配,這取決于動(dòng)作的細(xì)節(jié)。典型臨時(shí)數(shù)據(jù)流添加到先前的輸出流, 隨后輸出數(shù)據(jù)流再分配到先前數(shù)據(jù)流(嵌套)。Nested streams總被緩沖,并且明確要求緩沖嵌套數(shù)據(jù)流或被擯除的內(nèi)容。</p><p> ?如果out JspWr
86、iter 對(duì)象數(shù)據(jù)緩沖區(qū)滿, 則取決于autoFlush屬性值,緩沖內(nèi)容自動(dòng)輸入到ServletResponse output stream ,消除溢出;或拋出緩沖溢出的信號(hào)。如果JspWriter不溢出, 寫(xiě)入的內(nèi)容將被直接送入ServletResponse輸出流。</p><p> JSP頁(yè)也能描述一些應(yīng)該發(fā)生的具體事件。在JSP 2.1, 可被描述的唯一事件是初始化和頁(yè)的損壞。在聲明元素“well-kno
87、wn methodnames”中描述。(參見(jiàn)JSP.11.1.1.1, “Protocol Seen by theJSP Page Author”).</p><p> JavaScript是用于瀏覽器的第一種具有通用目的、動(dòng)態(tài)的客戶端腳本語(yǔ)言。Netscape于1995年首先提出了JavaScript,但當(dāng)時(shí)將其稱(chēng)為L(zhǎng)iveScript。后來(lái)Netscape迅速地將LiveScript改名為JavaScrip
88、t,Java的開(kāi)發(fā)商Sun與他們?cè)谕荒臧l(fā)表了一項(xiàng)聲明。聲明中指出Java和JavaScript將互相補(bǔ)充,但它們是截然不同的技術(shù),這樣才打消了很多人對(duì)這兩項(xiàng)技術(shù)的錯(cuò)誤理解。</p><p> JavaScript為創(chuàng)建用戶界面控件提供了一種腳本語(yǔ)言。事實(shí)上,JavaScript在瀏覽器中插入了代碼邏輯。它可以支持這樣的效果:當(dāng)光標(biāo)在Web頁(yè)的某個(gè)位置移動(dòng)時(shí)驗(yàn)證用戶輸入或者變換圖像。</p>&l
89、t;p> Microsoft也編寫(xiě)出了自己的JavaScript版本并將其稱(chēng)為JScript。Microsoft和Netscape都支持一種圍繞JavaScript和JScript的核心特性并由(European Computer Manufacturers Association,ECMA)標(biāo)準(zhǔn)組織控制的腳本語(yǔ)言標(biāo)準(zhǔn)。ECMA將其腳本語(yǔ)言命名為ECMAScript。</p><p> servlet和
90、JSP經(jīng)常包括一些組織中常見(jiàn)的信息,如logo、版本、商標(biāo)或?qū)Ш綏l。Web應(yīng)用程序使用導(dǎo)入機(jī)制在任何所需的位置導(dǎo)入這些信息,因?yàn)檫@樣可以很容易地在一個(gè)地方改變內(nèi)容,然后維持在所有使用它的代碼中。有些信息是靜態(tài)的,永遠(yuǎn)不會(huì)或很少會(huì)改變,如組織的logo。在其他情況下,信息是動(dòng)態(tài)的,經(jīng)常在不可預(yù)見(jiàn)的時(shí)候改變,如必須針對(duì)每個(gè)用戶的文本歡迎語(yǔ)。在這兩種情況下,你可能都希望保證servlet或JSP可以獨(dú)立于所導(dǎo)入的內(nèi)容進(jìn)行開(kāi)發(fā),servlet或
91、JSP的實(shí)現(xiàn)在必要時(shí)正確地更新其導(dǎo)入的內(nèi)容。</p><p> 希望在JSP中導(dǎo)入不經(jīng)常改變的資源。在導(dǎo)入JSP頁(yè)面中使用include指令,并給予被導(dǎo)入的JSP代碼段.jsp擴(kuò)展名。</p><p> 希望在JSP每次接收請(qǐng)求時(shí),而不是在JSP轉(zhuǎn)換為servlet時(shí)導(dǎo)入內(nèi)容。使用jsp:include標(biāo)準(zhǔn)動(dòng)作。</p><p> 希望在JSP中根據(jù)從配置文件
92、取得的值,動(dòng)態(tài)地導(dǎo)入文件。使用jsp:include標(biāo)準(zhǔn)動(dòng)作。在外部特性文件中提供它的值,或作為部署描述文件中的配置參數(shù)來(lái)提供。</p><p> 希望在JSP文檔中導(dǎo)入一段XML文件,或?qū)隭ML語(yǔ)法的JSP頁(yè)面。要在每次請(qǐng)求時(shí)進(jìn)行導(dǎo)入,使用jsp:include標(biāo)準(zhǔn)動(dòng)作。如果要在翻譯階段進(jìn)行導(dǎo)入,使用jsp:directive。include元素。JSP的運(yùn)行原理與優(yōu)點(diǎn)</p><p&g
93、t; 在本節(jié)中簡(jiǎn)單介紹JSP的運(yùn)行原理與優(yōu)點(diǎn)。</p><p> 在一個(gè)JSP文件第一次被請(qǐng)求時(shí),JSP引擎把該JSP文件轉(zhuǎn)換成為一個(gè)Servlet。而這個(gè)引擎本身也是一個(gè)Servlet。JSP的運(yùn)行過(guò)程如下所示:</p><p> ?。?)JSP引擎先把該JSP文件轉(zhuǎn)換成一個(gè)Java源文件(Servlet),在轉(zhuǎn)換時(shí)如果發(fā)現(xiàn)JSP文件有任何語(yǔ)法錯(cuò)誤,轉(zhuǎn)換過(guò)程將中斷,并向服務(wù)端和客戶端
94、輸出出錯(cuò)信息。</p><p> ?。?)如果轉(zhuǎn)換成功,JSP引擎用javac把該Java源文件編譯成相應(yīng)的class文件。</p><p> ?。?)創(chuàng)建一個(gè)該Servlet(JSP頁(yè)面的轉(zhuǎn)換結(jié)果)的實(shí)例,該Servlet的jspInit()方法被執(zhí)行,jspInit()方法在Servlet的生命周期中只被執(zhí)行一次。</p><p> ?。?)jspService
95、()方法被調(diào)用來(lái)處理客戶端的請(qǐng)求。對(duì)每一個(gè)請(qǐng)求,JSP引擎創(chuàng)建一個(gè)新的線程來(lái)處理該請(qǐng)求。如果有多個(gè)客戶端同時(shí)請(qǐng)求該JSP文件,則JSP引擎會(huì)創(chuàng)建多個(gè)線程。每個(gè)客戶端請(qǐng)求對(duì)應(yīng)一個(gè)線程。以多線程方式執(zhí)行可以大大降低對(duì)系統(tǒng)的資源需求,提高系統(tǒng)的并發(fā)量及響應(yīng)時(shí)間。但不過(guò)也應(yīng)該注意多線程的編程限制,由于該Servlet始終駐于內(nèi)存,所以響應(yīng)是非??斓摹?lt;/p><p> ?。?)如果.jsp文件被修改了,服務(wù)器將根據(jù)設(shè)置決
96、定是否對(duì)該文件重新編譯,如果需要重新編譯,則將編譯結(jié)果取代內(nèi)存中的Servlet,并繼續(xù)上述處理過(guò)程。</p><p> ?。?)雖然JSP效率很高,但在第一次調(diào)用時(shí)由于需要轉(zhuǎn)換和編譯而有一些輕微的延 遲。此外,在任何時(shí)候如果由于系統(tǒng)資源不足的原因,JSP引擎將以某種不確定的方式將Servlet從內(nèi)存中移去。當(dāng)這種情況發(fā)生時(shí)jspDestroy()方法首先被調(diào)用。</p><p> ?。?/p>
97、7)然后Servlet實(shí)例便被標(biāo)記加入“垃圾收集”處理。可在jspInit()中進(jìn)行一些初始化工作,如建立與數(shù)據(jù)庫(kù)的連接,或建立網(wǎng)絡(luò)連接,從配置文件中取一些參數(shù)等,在jspDestory()中釋放相應(yīng)的資源。</p><p> 基于Java語(yǔ)言的JSP技術(shù)具有很多其他動(dòng)態(tài)網(wǎng)頁(yè)技術(shù)所沒(méi)有的特點(diǎn),具體表現(xiàn)在如下方面:</p><p> 1.簡(jiǎn)便性和有效性 </p><p
98、> JSP動(dòng)態(tài)網(wǎng)頁(yè)的編寫(xiě)與一般的靜態(tài)HTML的網(wǎng)頁(yè)編寫(xiě)是十分相似的。只是在原來(lái)的HTML網(wǎng)頁(yè)中加入一些JSP專(zhuān)有的標(biāo)簽,或是一些腳本程序(此項(xiàng)不是必需的)。這樣,一個(gè)熟悉HTML網(wǎng)頁(yè)編寫(xiě)的設(shè)計(jì)人員可以很容易進(jìn)行JSP網(wǎng)頁(yè)的開(kāi)發(fā)。而且開(kāi)發(fā)人員完全可以不自己編寫(xiě)腳本程序,而只是通過(guò)JSP獨(dú)有的標(biāo)簽使用別人已寫(xiě)好的部件來(lái)實(shí)現(xiàn)動(dòng)態(tài)網(wǎng)頁(yè)的編寫(xiě)。這樣,一個(gè)不熟悉腳本語(yǔ)言的網(wǎng)頁(yè)開(kāi)發(fā)者,完全可以利用JSP做出漂亮的動(dòng)態(tài)網(wǎng)頁(yè)。而這在其他的動(dòng)態(tài)網(wǎng)頁(yè)
99、開(kāi)發(fā)中是不可實(shí)現(xiàn)的。</p><p><b> 2.程序的獨(dú)立性</b></p><p> JSP是Java API家族的一部分,它擁有一般的Java程序的跨平臺(tái)的特性。換句話說(shuō),就是擁有程序的對(duì)平臺(tái)的獨(dú)立性,即Write once,Run anywhere!。</p><p><b> 3.程序的兼容性 </b>&
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 畢業(yè)論文外文翻譯-jsp技術(shù)簡(jiǎn)介及特點(diǎn)
- jsp技術(shù)簡(jiǎn)介及特點(diǎn)文獻(xiàn)翻譯
- JSP技術(shù)簡(jiǎn)介及特點(diǎn)文獻(xiàn)翻譯.doc
- 外文翻譯---jsp簡(jiǎn)介
- 外文翻譯---jsp簡(jiǎn)介
- 外文翻譯---servlet和jsp技術(shù)簡(jiǎn)介
- 外文文獻(xiàn)翻譯---servlet和jsp技術(shù)簡(jiǎn)介
- jsp 技術(shù)外文翻譯
- jsp技術(shù)外文翻譯
- jsp 外文翻譯--jsp及其web技術(shù)
- jsp技術(shù)概述外文翻譯
- 外文翻譯---jsp技術(shù)與主流java+ee開(kāi)源框架(ssh)技術(shù)簡(jiǎn)介
- 計(jì)算機(jī)專(zhuān)業(yè)畢業(yè)外文翻譯--jsp簡(jiǎn)介
- jsp外文翻譯--jsp技術(shù)概述與應(yīng)用框架
- jsp技術(shù)網(wǎng)站設(shè)計(jì)外文翻譯
- 外文翻譯--jsp及其web技術(shù)
- 外文翻譯--jsp及其web技術(shù)
- asp技術(shù)簡(jiǎn)介外文翻譯
- 外文翻譯---jsp動(dòng)態(tài)網(wǎng)站技術(shù)
- jsp外文翻譯
評(píng)論
0/150
提交評(píng)論