jsp技術(shù)概述與應(yīng)用框架外文翻譯_第1頁(yè)
已閱讀1頁(yè),還剩20頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、<p><b>  外文原文</b></p><p>  Overview of JSP Technology and JSP application frameworks</p><p>  Autor: Zambon Giulio/ Sekler Michael</p><p>  Source: Springer-Verlag

2、New York Inc</p><p>  Benefits of JSP</p><p>  JSP pages are translated into servlets. So, fundamentally, any task JSP pages can perform could also be accomplished by servlets. However, this und

3、erlying equivalence does not mean that servlets and JSP pages are equally appropriate in all scenarios. The issue is not the power of the technology, it is the convenience, productivity, and maintainability of one or the

4、 other. After all, anything you can do on a particular computer platform in the Java programming language you could also do in assemb</p><p>  ? It is easier to write and maintain the HTML. Your static code

5、is ordinary HTML: no extra backslashes, no double quotes, and no lurking Java syntax.</p><p>  ? You can use standard Web-site development tools. Even HTML tools that know nothing about JSP can be used bec

6、ause they simply ignore the JSP tags.</p><p>  ? You can divide up your development team. The Java programmers can work on the dynamic code. The Web developers can concentrate on the presentation layer. On l

7、arge projects, this division is very important. Depending on the size of your team and the complexity of your project, you can enforce a weaker or stronger separation between the static HTML and the dynamic content.</

8、p><p>  Now, this discussion is not to say that you should stop using servlets and use only JSP instead. By no means. Almost all projects will use both. For some requests in your project, you will use servlets.

9、 For others, you will use JSP. For still others, you will combine them with the MVC architecture . You want the appropriate tool for the job, and servlets, by themselves, do not complete your toolkit.</p><p>

10、;  2.Advantages of JSP Over Competing Technologies</p><p>  A number of years ago, Marty was invited to attend a small 20-person industry roundtable discussion on software technology. Sitting in the seat nex

11、t to Marty was James Gosling, inventor of the Java programming language. Sitting several seats away was a high-level manager from a very large software company in Redmond, Washington. During the discussion, the moderator

12、 brought up the subject of Jini, which at that time was a new Java technology. The moderator asked the manager what he thought of it,</p><p>  Now, the grievance that Gosling was airing was that he felt that

13、 this company would take technology from other companies and suborn it for their own purposes. But guess what? The shoe is on the other foot here. The Java community did not invent the idea of designing pages as a mixtur

14、e of static HTML and dynamic code marked with special tags. For example, ColdFusion did it years earlier. Even ASP (a product from the very software company of the aforementioned manager) popularized this approach be<

15、/p><p>  2.1 Versus .NET and Active Server Pages (ASP)</p><p>  . NET is well-designed technology from Microsoft. ASP.NET is the part that directly competes with servlets and JSP. The advantage

16、s of JSP are two fold.First, JSP is portable to multiple operating systems and Web servers; you aren't locked into deploying on Windows and IIS. Although the core .NET platform runs on a few non-Windows platforms, th

17、e ASP part does not. You cannot expect to deploy serious ASP.NET applications on multiple servers and operating systems. For some applications, this dif</p><p>  You could make the same argument when compari

18、ng JSP to the previous version of ColdFusion; with JSP you can use Java for the "real code" and are not tied to a particular server product. However, the current release of ColdFusion is within the context of a

19、 J2EE server, allowing developers to easily mix ColdFusion and servlet/JSP code.</p><p>  2.2 Versus PHP</p><p>  PHP (a recursive acronym for "PHP: Hypertext Preprocessor") is a free

20、, open-source, HTML-embedded scripting language that is somewhat similar to both ASP and JSP. One advantage of JSP is that the dynamic part is written in Java, which already has an extensive API for networking, database

21、access, distributed objects, and the like, whereas PHP requires learning an entirely new, less widely used language. A second advantage is that JSP is much more widely supported by tool and server vendors than i</p>

22、;<p>  2.3 Versus Pure Servlets</p><p>  JSP doesn't provide any capabilities that couldn't, in principle, be accomplished with servlets. In fact, JSP documents are automatically translated i

23、nto servlets behind the scenes. But it is more convenient to write (and to modify!) regular HTML than to use a zillion println statements to generate the HTML. Plus, by separating the presentation from the content, you c

24、an put different people on different tasks: your Web page design experts can build the HTML by using familiar tools and either lea</p><p>  Does this mean that you can just learn JSP and forget about servlet

25、s? Absolutely not! JSP developers need to know servlets for four reasons:</p><p>  1. JSP pages get translated into servlets. You can't understand how JSP works without understanding servlets.</p>

26、<p>  2. JSP consists of static HTML, special-purpose JSP tags, and Java code. What kind of Java code? Servlet code! You can't write that code if you don't understand servlet programming.</p><p&g

27、t;  3. Some tasks are better accomplished by servlets than by JSP. JSP is good at generating pages that consist of large sections of fairly well structured HTML or other character data. Servlets are better for generating

28、 binary data, building pages with highly variable structure, and performing tasks (such as redirection) that involve little or no output.</p><p>  4. Some tasks are better accomplished by a combination of se

29、rvlets and JSP than by either servlets or JSP alone. </p><p>  2.4 Versus JavaScript</p><p>  JavaScript, which is completely distinct from the Java programming language, is normally used to dy

30、namically generate HTML on the client, building parts of the Web page as the browser loads the document. This is a useful capability and does not normally overlap with the capabilities of JSP (which runs only on the serv

31、er). JSP pages still include SCRIPT tags for JavaScript, just as normal HTML pages do. In fact, JSP can even be used to dynamically generate the JavaScript that will be sent to the </p><p>  It is also possi

32、ble to use JavaScript on the server, most notably on Sun ONE (formerly iPlanet), IIS, and BroadVision servers. However, Java is more powerful, flexible, reliable, and portable.</p><p>  2.5 Versus WebMacro

33、or Velocity</p><p>  JSP is by no means perfect. Many people have pointed out features that could be improved. This is a good thing, and one of the advantages of JSP is that the specification is controlled b

34、y a community that draws from many different companies. So, the technology can incorporate improvements in successive releases.</p><p>  However, some groups have developed alternative Java-based technologie

35、s to try to address these deficiencies. This, in our judgment, is a mistake. Using a third-party tool like Apache Struts that augments JSP and servlet technology is a good idea when that tool adds sufficient benefit to c

36、ompensate for the additional complexity. But using a nonstandard tool that tries to replace JSP is a bad idea. When choosing a technology, you need to weigh many factors: standardization, portability, integrati</p>

37、<p>  Besides, the tremendous industry support for JSP and servlet technology results in improvements that mitigate many of the criticisms of JSP. For example, the JSP Standard Tag Library and the JSP 2.0 expressi

38、on language address two of the most well-founded criticisms: the lack of good iteration constructs and the difficulty of accessing dynamic results without using either explicit Java code or verbose jsp:useBean elements.&

39、lt;/p><p>  3. Misconceptions About JSP</p><p>  Forgetting JSP Is Server-Side Technology</p><p>  Here are some typical questions Marty has received (most of them repeatedly).</p&g

40、t;<p>  ? Our server is running JDK 1.4. So, how do I put a Swing component in a JSP page?</p><p>  ? How do I put an image into a JSP page? I do not know the proper Java I/O commands to read image fi

41、les.</p><p>  ? Since Tomcat does not support JavaScript, how do I make images that are highlighted when the user moves the mouse over them?</p><p>  ? Our clients use older browsers that do not

42、 understand JSP. What should we do?</p><p>  ? When our clients use "View Source" in a browser, how can I prevent them from seeing the JSP tags?</p><p>  All of these questions are bas

43、ed upon the assumption that browsers know something about the server-side process. But they do not. Thus:</p><p>  ? For putting applets with Swing components into Web pages, what matters is the browser'

44、s Java version—the server's version is irrelevant. If the browser supports the Java 2 platform, you use the normal APPLET (or Java plug-in) tag and would do so even if you were using non-Java technology on the server

45、.</p><p>  ? You do not need Java I/O to read image files; you just put the image in the directory for Web resources (i.e., two levels up from WEB-INF/classes) and output a normal IMG tag.</p><p&g

46、t;  ? You create images that change under the mouse by using client-side JavaScript, referenced with the SCRIPT tag; this does not change just because the server is using JSP.</p><p>  ? Browsers do not &quo

47、t;support" JSP at all—they merely see the output of the JSP page. So, make sure your JSP outputs HTML compatible with the browser, just as you would do with static HTML pages.</p><p>  ? And, of course

48、you need not do anything to prevent clients from seeing JSP tags; those tags are processed on the server and are not part of the output that is sent to the client.</p><p>  Confusing Translation Time with Re

49、quest Time</p><p>  A JSP page is converted into a servlet. The servlet is compiled, loaded into the server's memory, initialized, and executed. But which step happens when? To answer that question, reme

50、mber two points:</p><p>  ? The JSP page is translated into a servlet and compiled only the first time it is accessed after having been modified.</p><p>  ? Loading into memory, initialization,

51、and execution follow the normal rules for servlets.</p><p>  The most frequently misunderstood entries are highlighted. When referring to the table, note that servlets resulting from JSP pages use the _jspSe

52、rvice method (called for both GET and POST requests), not doGet or doPost. Also, for initialization, they use the jspInit method, not the init method.JSP page translated into servlet Servlet compiled Servlet loaded into

53、server's memory jspInit called _jspService called.</p><p>  4.What are application frameworks:</p><p>  A framework is a reusable, semi-complete application that can be specialized to produc

54、e custom applications [Johnson]. Like people, software applications are more alike than they are different. They run on the same computers, expect input from the same devices, output to the same displays, and save data t

55、o the same hard disks. Developers working on conventional desktop applications are accustomed to toolkits and development environments that leverage the sameness between applications. Applicatio</p><p>  A f

56、ramework provides developers with a set of backbone components that have the following characteristics:</p><p>  1.They are known to work well in other applications.</p><p>  2. They are ready t

57、o use with the next project.</p><p>  3. They can also be used by other teams in the organization.</p><p>  Frameworks are the classic build-versus-buy proposition. If you build it, you will und

58、erstand it when you are done—but how long will it be before you can roll your own? If you buy it, you will have to climb the learning curve—and how long is that going to take? There is no right answer here, but most obse

59、rvers would agree that frameworks such as Struts provide a significant return on investment compared to starting from scratch, especially for larger projects.</p><p>  Other types of frameworks:</p>&

60、lt;p>  The idea of a framework applies not only to applications but to application componentsas well. Throughout this article, we introduce other types of frameworks that you can use with Struts. These include the Luc

61、ene search engine, the Scaffold toolkit, the Struts validator, and the Tiles tag library. Like application frameworks, these tools provide semi-complete versions of a subsystem that can be specialized to provide a custom

62、 component.</p><p>  Some frameworks have been linked to a proprietary development environment. This is not the case with Struts or any of the other frameworks shown in this book. You can use any development

63、 environment with Struts: Visual Age for Java, JBuilder, Eclipse, Emacs, and Textpad are all popular choices among Struts developers. If you can use it with Java, you can use it with Struts.</p><p>  Enablin

64、g technologies:</p><p>  Applications developed with Struts are based on a number of enabling technologies.These components are not specific to Struts and underlie every Java web application. A reason that d

65、evelopers use frameworks like Struts is to hide the nasty details behind acronyms like HTTP, CGI, and JSP. As a Struts developer, you don’t need to be an alphabet soup guru, but a working knowledge of these base technolo

66、gies can help you devise creative solutions to tricky problems.</p><p>  Hypertext Transfer Protocol (HTTP):</p><p>  When mediating talks between nations, diplomats often follow a formal protoc

67、ol.</p><p>  Diplomatic protocols are designed to avoid misunderstandings and to keep negotiations from breaking down. In a similar vein, when computers need to talk, they also follow a formal protocol. The

68、protocol defines how data is transmitted and how to decode it once it arrives. Web applications use the Hypertext Transfer Protocol (HTTP) to move data between the browser running on your computer and the application run

69、ning on the server.</p><p>  Many server applications communicate using protocols other than HTTP. Some of these maintain an ongoing connection between the computers. The application server knows exactly who

70、 is connected at all times and can tell when a connection is dropped. Because they know the state of each connection and the identity of each person using it, these are known as stateful protocols.</p><p>  

71、By contrast, HTTP is known as a stateless protocol. An HTTP server will accept any request from any client and will always provide some type of response, even if the response is just to say no. Without the overhead of ne

72、gotiating and retaining a connection, stateless protocols can handle a large volume of requests. This is one reason why the Internet has been able to scale to millions of computers.</p><p>  Another reason H

73、TTP has become the universal standard is its simplicity. An HTTP request looks like an ordinary text document. This has made it easy for applications to make HTTP requests. You can even send an HTTP request by hand using

74、 a standard utility such as Telnet. When the HTTP response comes back, it is also in plain text that developers can read.</p><p>  The first line in the HTTP request contains the method, followed by the loca

75、tionof the requested resource and the version of HTTP. Zero or more HTTP request headers follow the initial line. The HTTP headers provide additional information to the server. This can include the browser type and versi

76、on, acceptable document types, and the browser’s cookies, just to name a few. Of the seven request methods, GET and POST are by far the most popular.</p><p>  Once the server has received and serviced the re

77、quest, it will issue an HTTP response. The first line in the response is called the status line and carries the HTTP protocol version, a numeric status, and a brief description of the status. Following the status line, t

78、he server will return a set of HTTP response headers that work in a way similar to the request headers.</p><p>  As we mentioned, HTTP does not preserve state information between requests.The server logs the

79、 request, sends the response, and goes blissfully on to the next request. While simple and efficient, a stateless protocol is problematic for dynamic applications that need to keep track of their users. (Ignorance is not

80、 always bliss.</p><p>  Cookies and URL rewriting are two common ways to keep track of users between requests. A cookie is a special packet of information on the user’s computer. URL rewriting stores a speci

81、al reference in the page address that a Java server can use to track users. Neither approach is seamless, and using either means extra work when developing a web application. On its own, a standard HTTP web server does n

82、ot traffic in dynamic content. It mainly uses the request to locate a file and then returns that </p><p>  Standard web servers handle static content and images quite well but need a helping hand to provide

83、users with a customized, dynamic response. </p><p>  DEFINITION:Static content on the Web comes directly from text or data files, like HTML or JPEG files. These files might be changed from time to time, but

84、they are not altered automatically when requested by a web browser. Dynamic content, on the other hand, is generated on the fly, typically in response to an individualized request from a browser.</p><p>  Co

85、mmon Gateway Interface (CGI):</p><p>  The first widely used standard for producing dynamic content was the Common Gateway Interface (CGI). CGI uses standard operating system features, such as environment va

86、riables and standard input and output, to create a bridge, or gateway, between the web server and other applications on the host machine. The other applications can look at the request sent to them by the web server and

87、create a customized response.</p><p>  When a web server receives a request that’s intended for a CGI program, it runs that program and provides the program with information from the incoming request. The CG

88、I program runs and sends its output back to the server. The web server then relays the response to the browser.</p><p>  CGI defines a set of conventions regarding what information it will pass as environmen

89、t variables and how it expects standard input and output to be used. Like HTTP, CGI is flexible and easy to implement, and a great number of CGI-aware programs have been written.</p><p>  The main drawback t

90、o CGI is that it must run a new copy of the CGI-aware program for each request. This is a relatively expensive process that can bog down high-volume sites where thousands of requests are serviced per minute. Another draw

91、back is that CGI programs tend to be platform dependent. A CGI program written for one operating system may not run on another.</p><p>  5. Java servlets:</p><p>  Sun’s Java Servlet platform di

92、rectly addresses the two main drawbacks of CGI programs.First, servlets offer better performance and utilization of resources than conventional CGI programs. Second, the write-once, run-anywhere nature of Java means that

93、 servlets are portable between operating systems that have a Java Virtual Machine (JVM).</p><p>  A servlet looks and feels like a miniature web server. It receives a request and renders a response. But, unl

94、ike conventional web servers, the servlet application programming interface (API) is specifically designed to help Java developers create dynamic applications.</p><p>  The servlet itself is simply a Java cl

95、ass that has been compiled into byte code, like any other Java object. The servlet has access to a rich API of HTTP-specific services, but it is still just another Java object running in an application and can leverage a

96、ll your other Java assets.</p><p>  To give conventional web servers access to servlets, the servlets are plugged into containers. The servlet container is attached to the web server. Each servlet can declar

97、e what URL patterns it would like to handle. When a request matching a registered pattern arrives, the web server passes the request to the container, and the container invokes the servlet.</p><p>  But unli

98、ke CGI programs, a new servlet is not created for each request. Once the container instantiates the servlet, it will just create a new thread for each request. Java threads are much less expensive than the server process

99、es used by CGI programs. Once the servlet has been created, using it for additional requests incurs very little overhead. Servlet developers can use the init() method to hold references to expensive resources, such as da

溫馨提示

  • 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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 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ì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論