计算机 JSP web 外文翻译 外文文献

合集下载

Servlet和JSP文献翻译外文文献

Servlet和JSP文献翻译外文文献

毕业设计(论文)外文Servlet和JSP文献翻译附件1:外文资料翻译译文Servlet和JSP技术简述Nagle and Wiegley,Aug. 2020,953 – 958.摘要:Servlet程序在效劳器端运行,动态地生成Web页面与传统的CGI和许多其他类似CGI的技术相较,Java Servlet具有更高的效率,更易利用,功能更壮大,具有更好的可移植性,更节省投资。

关键字:JSP技术,Servlet,HTTP效劳Servlet的功能Servlets是运行在Web或应用效劳器上的Java程序,它是一个中间层,负责连接来自Web 阅读器或其他HTTP客户程序的请求和HTTP效劳器上的数据库或应用程序。

Servlet的工作是执行西门的任务,如下图。

图中间件的作用(1)读取客户发送的显式数据。

最终用户一样在页面的HTML表单中输入这些数据。

可是,数据还有可能来自applet或定制的HTTP客户程序。

(2)读取由阅读器发送的隐式请求数据。

图中显示了一条从客户端到Web效劳器的单箭头,但事实上从客户端传送到Web效劳器的数据有两种,它们别离为用户在表单中输入的显式数据,和后台的HTTP信息。

两种数据都很重要。

HTTP信息包括cookie、阅读器所能识别的媒体类型和紧缩模式等。

(3)生成结果。

那个进程可能需要访问数据库、执行RMI或EJB挪用、挪用Web效劳,或直接计算得出对应的响应。

实际的数据可能存储在关系型数据库中。

该数据库可能不睬解HTTP,或不能返回HTML 形式的结果,所有Web阅读器不能直接与数据库进行会话。

即便它能够做到这一点,为了平安上的考虑,咱们也不希望让它这么做。

对应大多数其他应用程序,也存在类似的问题。

因此,咱们需要Web中间层从HTTP流中提取输入数据,与应用程序会话,并将结果嵌入到文档中。

(4)向客户发送显式数据(即文档)。

那个文档能够用各类格式发送,包括文本(HTML或XML),二进制(GIF图),乃至能够式成立在其他底层格式之上的紧缩格式,如gzip。

jsp技术网站设计外文翻译(适用于毕业论文外文翻译+中英文对照)

jsp技术网站设计外文翻译(适用于毕业论文外文翻译+中英文对照)

Combining JSP and ServletsThe technology of JSP and Servlet is the most important technology which use Java technology to exploit request of server, 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 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 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 separating 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), 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 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 HTML 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, 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 powerful, 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 / 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 the 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, 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 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, 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 arrival of the first judgement is what type of request (GET / POST / HEAD…), then calls the appropriate treatment (DoGet / doPos t / doHead…) and generate a response.Although 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 container, which can provide session management and targeted life-cycle 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 cross-platform 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.It allows conventional static and dynamic HTML content generated by combining 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, 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 compile, 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 compiler, 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 pagesAfter 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, 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 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. combining JSP with servlets lets you clearly separate the application logic from the presentation of the application; in other words, 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 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. The API consists of two packages: the javax.servlet package contains classes and interfaces that are protocol-independent, while the javax.servlet.http package provides HTTP-specific extensions 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 support classes. This interface defines the methods used by the web container to manage and interact with theservlet. A servlet for processing HTTP requests typically extends 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 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 the instance. For an HttpServlet, the container calls the following methods at the appropriate times in the servlet lifecycle.Besides the doGet( ) and doPost( ) methods, there are methods corresponding to the other HTTP methods: doDelete( ), doHead( ), doOptions( ), doPut( ), and doTrace( ). Typically you don't implement these methods; 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 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 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 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 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 Servlet 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 the common/lib directory. On a Windows platform, you include the JAR file in the CLASSPATH.. Reading a RequestOne of the arguments passed to the doGet( ) and doPost( ) methods is an object that implements the HttpServletRequest interface. This interface defines methods that provide access to a wealth of information about the request.Generating a ResponseBesides the request object, the container passes an object that implements the HttpServletResponse interface as an argument to the doGet( ) and doPost( ) 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 and headers.Using Filters and ListenersThe servlet specification defines two component types beside servlets: filters and listeners. These two types were introduced in the Servlet 2.3 specification, so if you're using a container that doesn't yet support this version of the specification, I'm afraid you'reout of luck.FiltersA filter is 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 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 application. 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 response body if the Accept-Language request header indicates that the client can handle a compressed response.A filter can be applied to either a specific servlet or 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 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 could do this by letting the object saved as a sessionattribute(using the HttpSession.setAttribute() method)implement the HttpSessionBindingListener interface. With the new interfaces introduced in the 2.3 version of the 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 temporarily 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 binding 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. 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 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 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 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 initialization 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 the 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 this type of resource initialization. This type of listener implements the javax.servlet.ServletContextListener interface, with methods called by the container when the application starts and when it shuts down.Picking the Right Component Type for Each TaskThe Project Billboard application introduced is a fairly complex application. Half thepages 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 contain 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, 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 application 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 main requirements and see how we can map them to appropriate component types:●Database access should be abstracted, to avoid knowledge of a specific dataschema or database engine in more than one part of the application: beans in therole of Model can be used to accomplish this.●The database access beans must be made available to all other parts of theapplication when it starts: an application lifecycle event listener is the perfectcomponent type for this task.●Only authenticated users must be allowed to use the application: a filter canperform access control to satisfy this requirement.●Request processing is best done with Java code: a servlet, acting as the Controller,fits the bill.●It must be easy to change the presentation: this is where JSP shines, acting as theView.Adding servlets, listeners, and filters to the mix minimizes the need for complex logic in the JSP pages. Placing all this code in Java classes instead makes it possible to use a regular Java compiler and debugger to fix potential problems.Centralized Request Processing Using a ServletWith a servlet as the common entry point for all application requests, you gain control over the page flow of the application. The servlet can decide which type of response to generate depending on the outcome of the requested action, such as returning a common error page for all requests that fail, or different responses depending on the type of client making the request. With the help from some utility classes, it can also provide services such as input validation, I18N preparations, and in general, encourage a more streamlined approach to request handling.When you use a servlet as a Controller, you must deal with the following basic requirements:●All requests for processing must be passed to the single Controller servlet.●The servlet must be able to distinguish requests for different types of processing.Here are other features you will want support for, even though they may not be requirements for all applications:● A strategy for extending the application to support new types of processingA mechanism for changing the page flow of the application without modifyingcode.Mapping Application Requests to the ServletThe first requirement for using a Controller servlet is that all requests must pass through it. This can be satisfied in many ways. If you have played around a bit with servlets previously, you're probably used to invoking a servlet with a URI that starts with /myApp/servlet. This is a convention introduced by Suns Java Web Server (JWS), the first product to support servlets before the API was standardized. Most servlet containers support this convention today, even though it's not formally defined in the servlet specification.将Servlet和JSP组合使用Servlet和JSP技术是用Java开发服务器端应用的主要技术,是开发商务应用表示端的标准。

JSP及其WEB技术毕业设计论文中英文资料对照外文翻译文献

JSP及其WEB技术毕业设计论文中英文资料对照外文翻译文献

中英文资料对照外文翻译文献JSP及其WEB技术. 1 JSP简介JSP(JavaServer Pages)是一种基于Java的脚本技术。

是由Sun Microsystems 公司倡导、许多公司参与一起建立的一种动态网页技术标准。

JSP技术有点类似ASP 技术,它是在传统的网页HTML文件(*.htm,*.html)中插入Java程序段(Scriptlet)和JSP标记(tag),从而形成JSP文件(*.jsp)。

用JSP开发的Web应用是跨平台的,即能在Linux下运行,也能在其他操作系统上运行。

在JSP 的众多优点之中,其中之一是它能将 HTML 编码从 Web 页面的业务逻辑中有效地分离出来。

用 JSP 访问可重用的组件,如 Servlet、JavaBean 和基于 Java 的 Web 应用程序。

JSP 还支持在Web 页面中直接嵌入 Java 代码。

可用两种方法访问 JSP 文件:浏览器发送 JSP 文件请求、发送至 Servlet 的请求。

JSP技术使用Java编程语言编写类XML的tags 和scriptlets,来封装产生动态网页的处理逻辑。

网页还能通过tags和scriptlets 访问存在于服务端的资源的应用逻辑。

JSP将网页逻辑与网页设计和显示分离,支持可重用的基于组件的设计,使基于Web的应用程序的开发变得迅速和容易。

Web服务器在遇到访问JSP网页的请求时,首先执行其中的程序段,然后将执行结果连同JSP文件中的HTML代码一起返回给客户。

插入的Java程序段可以操作数据库、重新定向网页等,以实现建立动态网页所需要的功能。

JSP与Java Servlet一样,是在服务器端执行的,通常返回该客户端的就是一个HTML文本,因此客户端只要有浏览器就能浏览。

JSP页面由HTML代码和嵌入其中的Java代码所组成。

服务器在页面被客户端请求以后对这些Java代码进行处理,然后将生成的HTML页面返回给客户端的浏览器。

JSP技术中英文对照外文翻译文献

JSP技术中英文对照外文翻译文献

(文档含英文原文和中文翻译)中英文对照外文翻译JSP技术Java Server Pages(JSP)是一种基于web的脚本编程技术,类似于网景公司的服务器端Java脚本语言—— server-side JavaScript(SSJS)和微软的Active Server Pages(ASP)。

与SSJS和ASP相比,JSP具有更好的可扩展性,并且它不专属于任何一家厂商或某一特定的Web服务器。

尽管JSP规范是由Sun公司制定的,但任何厂商都可以在自己的系统上实现JSP。

在Sun正式发布JSP(Java Server Pages)之后,这种新的Web应用开发技术很快引起了人们的关注。

JSP为创建高度动态的Web应用提供了一个独特的开发环境。

按照Sun的说法,JSP能够适应市场上包括Apache WebServer、IIS4.0在内的85%的服务器产品。

本文将介绍JSP相关的知识,以及JavaBean的相关内容,当然都是比较粗略的介绍其中的基本内容,仅仅起到抛砖引玉的作用,如果读者需要更详细的信息,请参考相应的JSP的书籍。

1.1 概述JSP(Java Server Pages)是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准,其在动态网页的建设中有其强大而特别的功能。

JSP与Microsoft的ASP技术非常相似。

两者都提供在HTML代码中混合某种程序代码、由语言引擎解释执行程序代码的能力。

下面我们简单的对它进行介绍。

JSP页面最终会转换成servlet。

因而,从根本上,JSP页面能够执行的任何任务都可以用servlet来完成。

然而,这种底层的等同性并不意味着servlet和JSP 页面对于所有的情况都等同适用。

问题不在于技术的能力,而是二者在便利性、生产率和可维护性上的不同。

毕竟,在特定平台上能够用Java编程语言完成的事情,同样可以用汇编语言来完成,但是选择哪种语言依旧十分重要。

JSP技术-外文文献

JSP技术-外文文献

外文文献JSP Technology and ServletsJSP profileJSP (JavaServer Pages) is initiated by Sun Microsystems, Inc., with many companies to participate in the establishment of a dynamic we b page technical standards. JSP technology somewhat similar to ASP technology, it is in the traditional HTML web page document (*. htm, *. html) to insert the Java 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 also available for ot her operating systems.JSP technology to use the Java programming language prepared by the category of XML tags and scriptlets, to produce dynamic page s 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 and 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 implem entation of the procedures of, and then together with the results of th e implementation of JSP documents in HTML code with the return to the customer. Insert 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, is in the impl ementation of the server, usually returned to the client is an HTML te xt, as long as the client browser will be able to visit.JSP 1.0 specification of the final version is launched in September 1999, December has introduced 1.1 specifications. At present relative ly new is JSP1.2 norms, JSP2.0 norms of the draft has also been introd uced.JSP pages from HTML code and Java code embedded in one of t he components.JS script language synopsisJS is javascrip, Javascript is one kind the script language which co mes by the Netscape LiveScript development, the main purpose is to solve the server terminal language, for instance Perl, carry-over speed question. At that time served the end to need to carry on the confirmation to the data, because the network speed was quite sl ow, only then 28.8kbps, the confirmation step waste's time were too many. Therefore Netscape browser Navigator has joined Javascript, h as provided the data confirmation basic function.The JavaScript official name is “ECMAScript”. This standard by ECMA organization development and maintenance. ECMA262 is the o fficial JavaScript standard. This standard based on JavaScript (Netscap e) and JScript (Microsoft). Netscape (Navigator 2.0) Brendan Eich has i nvented this language, started from 1996, already appeared in all Net scape and in the Microsoft browser. The ECMA262 development bega n in 1996, in 1997 July, the ECMA general meeting has accepted its fir st edition.The script uses one specific descriptive language, rests on certain form compilation to be possible the execution document, is also call ed as great or the batch run document. The script usually may transfe r temporarily by the application procedure and carry out. Each kind o f script present widely is applied in the homepage design, because th e script not only may reduce the homepage the scale and raises the h omepage browsing speed, moreover may enrich the homepage perfo rmance, like animation, sound and so on. Cites a most common exam ple, when we click in the homepage the Email address can transfer O utlook Express or the Foxmail this kind of mail software automatically, is realizes through the script function. Also because of script these ch aracteristics, the human who harbors ulterior motives by some are oft en using. For example joins some destruction computer system's ord er in the script, like this works as the user browsing homepage, once t ransfers this kind of script, will then cause the user the system to com e under the attack. Therefore the user should act according to visits h omepage the trust degree selective security rank, specially regardingthese itself content on the illegal homepage, do not permit the use sc ript easily. Through “the safe establishment” the dialog box, the ch oice “the script” under option each kind of establishment may with ease realize to script being forbid and begins using.JSP and ServletsThe technology of JSP and Servlet is the most important technol ogy which use Javatechnology to exploit request of server, and it is also the standard which exploit business application .Java developers prefer to use it fo r a variety of reasons, one of which is already familiar with the Java la nguage for the development of this technology are easy to learn Java to the other is "a preparation, run everywhere" to bring the concept of Web applications, To achieve a "one-prepared everywhere realized." And more importantly, if followed so me of the principles of good design, it can be said of separating and content to create high-quality, reusable, easy to maintain and modify the application. For ex ample, if the document in HTML embedded Java code too much (scri pt), will lead the developed application is extremely complex, difficult to read, it is not easy reuse, but also for future maintenance and modi fication will also cause difficulties. In fact, CSDN the JSP / Servlet foru m, can often see some questions, the code is very long, can logic is n ot very clear, a large number of HTML and Java code mixed together. This is the random development of the defects.Early dynamic pages mainly CGI (Common Gateway Interface, pu blic Gateway Interface) technology, you can use different languages o f the CGI programs, such as VB, C / C + + or Delphi, and so on. Thoug h the technology of CGI is developed and powerful, because of difficu lties in programming, and low efficiency, modify complex shortcomin gs, it is gradually being replaced by the trend. Of all the new technolo gy, JSP / Servlet with more efficient and easy to program, more powe rful, more secure and has a good portability, they have been many people believe that the future is the most dynamic site of the future dev elopment of technology.Similar to CGI, Servlet support request / response model. When a customer submit a request to the server, the server presented the re quest Servlet, Servlet responsible for handling requests and generate a response, and then gave the server, and then from the server sent t o the customer. And the CGI is different, Servlet not generate a new p rocess, but with HTTP Server at the same process. It threads through the use of technology, reduce the server costs. Servlet handling of th e request process is this: When received from the client's request, calli ng service methods, the method of Servlet arrival of the first judgeme nt is what type of request (GET / POST / HEAD…), then calls the appro priate treatment (DoGet / doPost / doHead…) and generate a respons e.Although such a complex, in fact, simply said to Servlet is a Java c lass. And the general category of the difference is that this type oper ating in a Servlet container, which can provide session management a nd 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 effi cient Web applications.JSP technology is a key J2EE technology, it at a higher level of abs traction of a Servlet. It allows conventional static and dynamic HTML content generated by combining an HTML page looks like, but as a S ervlet to run. There are many commercial application server support J SP technology, such as BEA WebLogic, IBM WebSphere, JRun, and so on. JSP and Servlet use more than simple. If you have a JSP support f or Web servers, and a JSP document, you can put it Fangdao any stati c HTML files can be placed, do not have to compile, do not have to p ack, do not have to ClassPath settings, you can visit as ordinary Web I t did visit, the server will automatically help you to do other work.JSP document looks like an ordinary static HTML document, but i nside contains a number of Java code. It uses. Jsp the suffix, used to t ell the server this document in need of special treatment. When we vi sit a JSP page, the document will first be translated into a JSP engine Java source files, is actually a Servlet, and compiler, and then, like oth er Servlet, from Servlet engine to handle. Servlet engine of this type l oading, handling requests from customers, and the results returned t o the customer.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 t he implementation of the above process, 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 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 i nformation about the request, the session, and the application. combi ning JSP with servlets lets you clearly separate the application logic fr om the presentation of the application; in other words, it lets you use the most appropriate component type for the roles of Model, View a nd Controller.Servlets, Filters, and ListenersA servlet is a Java class that extends a server with functionality fo r processing a request and producing a response. It's implemented us ing the classes and interfaces defined by the Servlet API. The API con sists of two packages: the javax.servlet package contains classes and i nterfaces that are protocolindependent, while the javax.servlet.http p ackage provides HTTP-specific extensions and utility classes.What makes a servlet a servlet is that the class implements an int erface named javax.servlet.Servlet, either directly or by extending one of the support classes. This interface defines the methods used by the web container to manage and interact with theservlet. A servlet for processing HTTP requests typically extends the javax.servlet.http.HttpServlet class. This class implements the Servlet interface and provides additional methods suitable for HTTP processi ng.Servlet LifecycleThe web container manages all aspects of the servlet's lifecycle. It cr eates an instance of the servlet class when needed, passes requests t o the instance for processing, and eventually removes the instance. F or an HttpServlet, the container calls the following methods at the ap propriate times in the servlet lifecycle.Besides the doGet( ) and doPost( ) methods, there are methods corr esponding to the other HTTP methods: doDelete( ), doHead( ), doOpt ions( ), doPut( ), and doTrace( ). Typically you don't implement these methods; the HttpServlet class already takes care of HEAD, OPTIONS, and TRACE requests in a way that's suitable for most servlets, and th e DELETE and PUT HTTP methods are rarely used in a web application .It's important to realize that the container creates only one instan ce of each servlet. This means that the servlet must be thread safe - a ble to handle multiple requests at the same time, each executing as a separate thread through the servlet code. Without getting lost in det ails, you satisfy this requirement with regards to instance variables if y ou modify the referenced objects only in the init( ) and destroy( ) met hods, and just 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 Servlet API classes in the CLASSPATH environment v ariable. The JAR file is distributed with all web containers. Tomcat incl udes it in a file called servlet.jar, located in the common/lib directory. On a Windows platform, you include the JAR file in the CLASSPATH.Reading a RequestOne of the arguments passed to the doGet( ) and doPost( ) meth ods is an object that implements the HttpServletRequest interface. Th is interface defines methods that provide access to a wealth of inform ation about the request.Generating a ResponseBesides the request object, the container passes an object that impl ements the HttpServletResponse interface as an argument to the doG et( ) and doPost( ) methods. This interface defines methods for gettin g a writer or stream for the response body. It also defines methods fo r setting the response status code and headers.Using Filters and ListenersThe servlet specification defines two component types beside servle ts: filters and listeners. These two types were introduced in the Servle t 2.3 specification, so if you're using a container that doesn't yet supp ort this version of the specification, I'm afraid you're out of luck.FiltersA filter is a component that can intercept a request targeted for a servlet, JSP page, or static page, as well as the response before it's se nt to the client. This makes it easy to centralize tasks that apply to all requests, such as access control, logging, and charging for the conten t or the services offered by the application. A filter has full access to t he body and headers of the request and response, so it can also perf orm various transformations. One example is compressing the respon se body if the Acceptlanguage request header indicates that the clie nt can handle a compressed response.A filter can be applied to either a specific servlet or to all request s matching a URL pattern, such as URLs starting with the same path el ements or having the same extension.ListenersListeners allow your application to react to certain events. Prior t o Servlet 2.3, you could handle only session attribute binding events ( triggered when an object was added or removed from a session). You could do this by letting the object saved as a sessionattributimpleme nt the HttpSessionBindingListener interface. With the new interfaces introduced in the 2.3 version of the specification, you can create liste ners for servlet context and session lifecycle events as well as session activation and passivation events (used by a container that temporaril y saves session state to disk or migrates a session to another server).A newsession attribute event listener also makes it possible to deal wi th attribute binding events for all sessions in one place, instead of pla cing individual listener objects in each session.The new types of listeners follow the standard Java event model. I n other words, a listener is a class that implements one or more of th e listener interfaces. The interfaces define methods that correspond t o events. The listener class is registered with the container when the a pplication starts, and the container then calls the event methods at th e appropriate times.Initializing Shared Resources Using a ListenerBeans like this typically need to be initialized before they can be used. Forinstance, they may need a reference to a database or some other external data source and may create an initial information cache in m emory to provide fast access even to the first request for data. You ca n include code for initialization of the shared resources in the servlet and JSP pages that need them, but a more modular approach is to pl ace all this code in one place and let the other parts of the applicatio n work on the assumption that the resources are already initialized an d available. An application lifecycle listener is a perfect tool for this ty pe of resource initialization. This type of listener implements the javax.servlet.ServletContextListener interface, with methods called by the container when the application starts and when it shuts down.Picking the Right Component Type for Each TaskThe Project Billboard application introduced is a fairly complex ap plication. Half the pages are pure controller and business logic proces sing, it accesses a database to authenticate users, and most pages re quire access control. In real life, it would likely contain even more pag es, for instance, pages for access to a shared document archive, time schedules, and a set of pages for administration. As the application e volves, 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 application that can benefit from using a combi nation of JSP pages and the component types defined by the servlet specification for the MVC roles. Let's look at the main requirements a nd see how we can map them to appropriate component types: Database access should be abstracted, to avoid knowledge of a s pecific dataschema or database engine in more than one part of the application : beans in the role of Model can be used to accomplish this.The database access beans must be made available to all other p arts of theapplication when it starts: an application lifecycle event listener is th e perfect component type for this task.Only authenticated users must be allowed to use the application: a fil ter canperform access control to satisfy this requirement.Request processing is best done with Java code: a servlet, acting as the Controller fits the bill.It must be easy to change the presentation: this is where JSP shines, acting as the View.Adding servlets, listeners, and filters to the mix minimizes the n eed for complex logic in the JSP pages. Placing all this code in Java classes instead makes it possible to use a regular Java compiler and de bugger to fix potential problems.Centralized Request Processing Using a ServletWith a servlet as the common entry point for all application re quests, you gain control over the page flow of the application. The se rvlet can decide which type of response to generate depending on th e outcome of the requested action, such as returning a common error page for all requests that fail, or different responses depending on th e type of client making the request. With the help from some utility cl asses, it can also provide services such as input validation, I18N prepa rations, and in general, encourage a more streamlined approach to re quest handling.Mapping Application Requests to the ServletThe first requirement for using a Controller servlet is that all re quests must pass through it. This can be satisfied in many ways. If yo u have played around a bit with servlets previously, you're probably u sed to invoking a servlet with a URI that starts with /myApp/servlet. T his is a convention introduced by Suns Java Web Server (JWS), the firs t product to support servlets before the API was standardized. Most s ervlet containers support this convention today, even though it's not formally defined in the servlet specification.。

JSP技术 ---外文文献

JSP技术 ---外文文献

外文文献JSP Technology and ServletsJSP profileJSP (JavaServer Pages) is initiated by Sun Microsystems , Inc., with many companies to participate in the establi shment of a dynamic web page technical standards. JSP tec hnology somewhat similar to ASP technology, it is in the traditional HTML web page document (*. htm, *. html) to insert the Java programming paragraph (Scriptlet) and JSP tag (tag), thus JSP documents (*. jsp). Using JSP devel opment of the Web application is cross that can run on Linux, is also available for other operating systems.JSP technology to use the Java programming language pr epared by the category of XML tags and scriptlets, to pr oduce dynamic pages package processing logic. Page also vi sit by tags and scriptlets exist in the services side of the resources of logic. JSP page logic and web page de sign and display separation, support reusable component-base d design, Web-based application development is rapid and e asy.Web server in the face of visits JSP page request, t he first implementation of the procedures of, and then to gether with the results of the implementation of JSP docu ments in HTML code with the return to the customer. Inse rt the Java programming operation of the database can be reoriented websites, in order to achieve the establishmen t of dynamic pages needed to function.JSP and Java Servle t, is in the implementation of the server, usually return ed to the client is an HTML text, as long as the clien t browser will be able to visit.JSP 1.0 specification 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 n orms of the draft has also been introduced.JSP pages from HTML code and Java code embedded in one of the compone nts.JS script language synopsisJS is javascrip, Javascript is one kind the script la nguage which comes by the Netscape LiveScript development, the main purpose is to solve the server terminal langua ge, for instance Perl, carry-over speed question. At that time served the end to need to carry on the confirmati on to the data, because the network speed was quite slow , only then 28.8kbps, the confirmation step waste's time were too many. Therefore Netscape browser Navigator has jo ined Javascript, has provided the data confirmation basic function.The JavaScript official name is “ECMAScript”.This st andard by ECMA organization development and maintenance. EC MA262 is the official JavaScript standard. This standard b ased on JavaScript (Netscape) and JScript (Microsoft). Nets cape (Navigator 2.0) Brendan Eich has invented this langua ge, started from 1996, already appeared in all Netscape a nd in the Microsoft browser. The ECMA262 development began in 1996, in 1997 July, the ECMA general meeting has ac cepted its first edition.The script uses one specific descriptive language, rest s on certain form compilation to be possible the executio n document, is also called as great or the batch run do cument. The script usually may transfer temporarily by the application procedure and carry out. Each kind of script present widely is applied in the homepage design, becaus e the script not only may reduce the homepage the scale and raises the homepage browsing speed, moreover may enr ich the homepage performance, like animation, sound and so on. Cites a most common example, when we click in the 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 ofscript these characteristics, the human who harbors ulterio r motives by some are often using. For example joins som e destruction computer system's order in the script, like this works as the user browsing homepage, once transfers this kind of script, will then cause the user the syst em to come under the attack. Therefore the user should a ct according to visits homepage the trust degree selective security rank, specially regarding these itself content o n the illegal homepage, do not permit the use script eas ily. Through “the safe establishment”the dialog box, th e choice “the script”under option each kind of establi shment may with ease realize to script being forbid and begins using.JSP and ServletsThe technology of JSP and Servlet is the most importa nt technology which use Javatechnology to exploit request of server, and it is al so the standard which exploit business application .Java d evelopers prefer to use it for a variety of reasons, one of which is already familiar with the Java language for the development of this technology are easy to learn Ja va to the other is "a preparation, run everywhere" to br ing the concept of Web applications, To achieve a "one-pr epared everywhere realized." And more importantly, if follo wed some of the principles of good design, it can be sa id of separating and content to create high-quality, reusa ble, easy to maintain and modify the application. For exa mple, if the document in HTML embedded Java code too muc h (script), will lead the developed application is extreme ly complex, difficult to read, it is not easy reuse, but also for future maintenance and modification will also c ause difficulties. In fact, CSDN the JSP / Servlet forum, can often see some questions, the code is very long, c an logic is not very clear, a large number of HTML and Java code mixed together. This is the random development of the defects.Early dynamic pages mainly CGI (Common Gateway Interfac e, public Gateway Interface) technology, you can use diffe rent languages of the CGI programs, such as VB, C / C + + or Delphi, and so on. Though the technology of CGI is developed and powerful, because of difficulties in pr ogramming, and low efficiency, modify complex shortcomings, it is gradually being replaced by the trend. Of all th e new technology, JSP / Servlet with more efficient and easy to program, more powerful, more secure and has a good portability, they have been many people believe that t he future is the most dynamic site of the future develop ment of technology.Similar to CGI, Servlet support request / response mod el. When a customer submit a request to the server, 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 the customer. And the CGI is different, Servlet not generate a new process, but with HTTP Server at the same proces s. It threads through the use of technology, reduce the server costs. Servlet handling of the request process is this: When received from the client's request, calling ser vice 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 complex, in fact, simply said to Serv let is a Java class. And the general category of the di fference is that this type operating in a Servlet contain er, which can provide session management and targeted life cycle 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 datab ase and crossplatform capability. Moreover, Servlet using t hread, and can develop more efficient Web applications.JSP technology is a key J2EE technology, it at a hig her level of abstraction of a Servlet. It allows conventi onal static and dynamic HTML content generated by combinin g an HTML page looks like, but as a Servlet to run. Th ere are many commercial application server support JSP tec hnology, such as BEA WebLogic, IBM WebSphere, JRun, and s o on. JSP and Servlet use more than simple. If you havea JSP support for Web servers, and a JSP document, youcan put it Fangdao any static HTML files can be placed , do not have to compile, do not have to pack, do nothave to ClassPath settings, you can visit as ordinary W eb It did visit, the server will automatically help you to do other work.JSP document looks like an ordinary static HTML docume nt, 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 compiler, and then, like other Servlet, from Servlet engine to ha ndle. Servlet engine of this type loading, handling reques ts from customers, and the results returned to the custom er.After another visit this page to the customer, as lon g as the paper there have been no changes, JSP engine h as been loaded directly call the Servlet. If you have al ready been modified, it will be once again the implementa tion of the above process, translate, compile and load. I n fact, this is the so-called "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 acces s to all the information about the request, the session, and the application. combining JSP with servlets lets yo u clearly separate the application logic from the presenta tion of the application; in other words, 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 that extends a server withfunctionality for processing a request and producing a r esponse. It's implemented using the classes and interfaces defined by the Servlet API. The API consists of two pa ckages: the javax.servlet package contains classes and interfaces that are protocolindependent, while the javax.servlet .http package provides HTTP-specific extensions and utility classes.What makes a servlet a servlet is that the class imp lements an interface named javax.servlet.Servlet, either dir ectly or by extending one of the support classes. This i nterface defines the methods used by the web container to manage and interact with theservlet. A servlet for processing HTTP requests typically extends thejavax.servlet.http.HttpServlet class. This class implements the Servlet interface and provides additional methods suita ble for HTTP processing.Servlet LifecycleThe web container manages all aspects of the servlet's l ifecycle. It creates an instance of the servlet class whe n needed, passes requests to the instance for processing, and eventually removes the instance. For an HttpServlet, the container calls the following methods at the appropr iate times in the servlet lifecycle.Besides the doGet( ) and doPost( ) methods, there are m ethods corresponding to the other HTTP methods: doDelete( ), doHead( ), doOptions( ), doPut( ), and doTrace( ). Ty pically you don't implement these methods; the HttpServle t class already takes care of HEAD, OPTIONS, and TRACE r equests in a way that's suitable for most servlets, and the DELETE and PUT HTTP methods are rarely used in a we b application.It's important to realize that the container creates o nly one instance of each servlet. This means that the se rvlet must be thread safe - able to handle multiple requ ests at the same time, each executing as a separate thre ad through the servlet code. Without getting lost in deta ils, you satisfy this requirement with regards to instance variables if you modify the referenced objects only inthe init( ) and destroy( ) methods, and just 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 Servlet API classes in the CLASSPATH environment variable. The JAR file is dist ributed with all web containers. Tomcat includes it in a file called servlet.jar, located in the common/lib direct ory. On a Windows platform, you include the JAR file in the CLASSPATH.Reading a RequestOne of the arguments passed to the doGet( ) and doPo st( ) methods is an object that implements the HttpServle tRequest interface. This interface defines methods that pro vide access to a wealth of information about the request.Generating a ResponseBesides the request object, the container passes an objec t that implements the HttpServletResponse interface as an argument to the doGet( ) and doPost( ) methods. This int erface defines methods for getting a writer or stream for the response body. It also defines methods for setting the response status code and headers.Using Filters and ListenersThe servlet specification defines two component types besi de servlets: filters and listeners. These two types were introduced in the Servlet 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 a component that can intercept a request targeted for a servlet, JSP page, or static page, as w ell as the response before it's sent to the client. This makes it easy to centralize tasks that apply to all re quests, such as access control, logging, and charging for the content or the services offered by the application.A filter has full access to the body and headers of t he request and response, so it can also perform various transformations. One example is compressing the response bo dy if the Acceptlanguage request header indicates that th e client can handle a compressed response.A filter can be applied to either a specific servlet or to all requests matching a URL pattern, such as URL s starting with the same path elements or having the sam e extension.ListenersListeners allow your application to react to certain e vents. Prior to Servlet 2.3, you could handle only sessio n attribute binding events (triggered when an object was added or removed from a session). You could do this by letting the object saved as a sessionattributimplement the HttpSessionBindingListener interface. With the new interfa ces introduced in the 2.3 version of the specification, y ou can create listeners for servlet context and session l ifecycle events as well as session activation and passivat ion events (used by a container that temporarily saves se ssion state to disk or migrates a session to another ser ver). A newsession attribute event listener also makes it possible to deal with attribute binding events for all sessions in one place, instead of placing individual liste ner objects in each session.The new types of listeners follow the standard Java e vent model. In other words, a listener is a class that implements one or more of the listener interfaces. The in terfaces define methods that correspond to events. The lis tener class is registered with the container when the app lication starts, and the container then calls the event m ethods at the appropriate times.Initializing Shared Resources Using a ListenerBeans like this typically need to be initialized befor e they can be used. Forinstance, they may need a reference to a database or some other external data source and may create an initi al information cache in memory to provide fast access eve n to the first request for data. You can include code f or initialization of the shared resources in the servlet and JSP pages that need them, but a more modular approac h is to place all this code in one place and let the other parts of the application work on the assumption tha t the resources are already initialized and available. An application lifecycle listener is a perfect tool for thi s type of resource initialization. This type of listener implements the javax.servlet.ServletContextListener interface , with methods called by the container when the applicati on starts and when it shuts down.Picking the Right Component Type for Each TaskThe Project Billboard application introduced is a fairl y complex application. Half the pages 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 contain even more pages, for instance, pages for access to a shared document arc hive, time schedules, and a set of pages for administrati on. As the application evolves, it may become hard to ma intain as a pure JSP application. It's easy to forget to include the access control code in new pages.This is clearly an application 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 main requirements and see how we can map them to appropriate component types:Database access should be abstracted, to avoid knowledg e of a specific dataschema or database engine in more than one part of the application: beans in the role of Model can be used to accomplish this.The database access beans must be made available to a ll other parts of theapplication when it starts: an application lifecycle event listener is the perfect component type for this task.Only authenticated users must be allowed to use the appli cation: a filter canperform access control to satisfy this requirement.Request processing is best done with Java code: a servlet, acting as the Controller fits the bill.It must be easy to change the presentation: this is where JSP shines, acting as the View.Adding servlets, listeners, and filters to the mix m inimizes the need for complex logic in the JSP pages. Pl acing all this code in Java classes instead makes it pos sible to use a regular Java compiler and debugger to fix potential problems.Centralized Request Processing Using a ServletWith a servlet as the common entry point for all a pplication requests, you gain control over the page flowof the application. The servlet can decide which type of response to generate depending on the outcome of the re quested action, such as returning a common error page for all requests that fail, or different responses depending on the type of client making the request. With the hel p from some utility classes, it can also provide services such as input validation, I18N preparations, and in general, encourage a more streamlined approach to request hand ling.Mapping Application Requests to the ServletThe first requirement for using a Controller servlet is that all requests must pass through it. This can be satisfied in many ways. If you have played around a bi t with servlets previously, you're probably used to invoki ng a servlet with a URI that starts with /myApp/servlet. This is a convention introduced by Suns Java Web Server (JWS), the first product to support servlets before the API was standardized. Most servlet containers support thi s convention today, even though it's not formally defined in the servlet specification.(注:专业文档是经验性极强的领域,无法思考和涵盖全面,素材和资料部分来自网络,供参考。

JSP技术 ---外文文献

JSP技术 ---外文文献

外文文献JSP Technology and ServletsJSP profileJSP (JavaServer Pages) is initiated by Sun Microsystems , Inc., with many companies to participate in the establi shment of a dynamic web page technical standards. JSP tec hnology somewhat similar to ASP technology, it is in the traditional HTML web page document (*. htm, *. html) to insert the Java programming paragraph (Scriptlet) and JSP tag (tag), thus JSP documents (*. jsp). Using JSP devel opment of the Web application is cross that can run on Linux, is also available for other operating systems.JSP technology to use the Java programming language pr epared by the category of XML tags and scriptlets, to pr oduce dynamic pages package processing logic. Page also vi sit by tags and scriptlets exist in the services side of the resources of logic. JSP page logic and web page de sign and display separation, support reusable component-base d design, Web-based application development is rapid and e asy.Web server in the face of visits JSP page request, t he first implementation of the procedures of, and then to gether with the results of the implementation of JSP docu ments in HTML code with the return to the customer. Inse rt the Java programming operation of the database can be reoriented websites, in order to achieve the establishmen t of dynamic pages needed to function.JSP and Java Servle t, is in the implementation of the server, usually return ed to the client is an HTML text, as long as the clien t browser will be able to visit.JSP 1.0 specification 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 n orms of the draft has also been introduced.JSP pages from HTML code and Java code embedded in one of the compone nts.JS script language synopsisJS is javascrip, Javascript is one kind the script la nguage which comes by the Netscape LiveScript development, the main purpose is to solve the server terminal langua ge, for instance Perl, carry-over speed question. At that time served the end to need to carry on the confirmati on to the data, because the network speed was quite slow , only then 28.8kbps, the confirmation step waste's time were too many. Therefore Netscape browser Navigator has jo ined Javascript, has provided the data confirmation basic function.The JavaScript official name is “ECMAScript”.This st andard by ECMA organization development and maintenance. EC MA262 is the official JavaScript standard. This standard b ased on JavaScript (Netscape) and JScript (Microsoft). Nets cape (Navigator 2.0) Brendan Eich has invented this langua ge, started from 1996, already appeared in all Netscape a nd in the Microsoft browser. The ECMA262 development began in 1996, in 1997 July, the ECMA general meeting has ac cepted its first edition.The script uses one specific descriptive language, rest s on certain form compilation to be possible the executio n document, is also called as great or the batch run do cument. The script usually may transfer temporarily by the application procedure and carry out. Each kind of script present widely is applied in the homepage design, becaus e the script not only may reduce the homepage the scaleand raises the homepage browsing speed, moreover may enr ich the homepage performance, like animation, sound and soon. Cites a most common example, when we click in the 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 of script these characteristics, the human who harbors ulterio r motives by some are often using. For example joins som e destruction computer system's order in the script, like this works as the user browsing homepage, once transfers this kind of script, will then cause the user the syst em to come under the attack. Therefore the user should a ct according to visits homepage the trust degree selective security rank, specially regarding these itself content o n the illegal homepage, do not permit the use script eas ily. Through “the safe establishment”the dialog box, th e choice “the script”under option each kind of establi shment may with ease realize to script being forbid and begins using.JSP and ServletsThe technology of JSP and Servlet is the most importa nt technology which use Javatechnology to exploit request of server, and it is al so the standard which exploit business application .Java d evelopers prefer to use it for a variety of reasons, one of which is already familiar with the Java language for the development of this technology are easy to learn Ja va to the other is "a preparation, run everywhere" to br ing the concept of Web applications, To achieve a "one-pr epared everywhere realized." And more importantly, if follo wed some of the principles of good design, it can be sa id of separating and content to create high-quality, reusa ble, easy to maintain and modify the application. For exa mple, if the document in HTML embedded Java code too much (script), will lead the developed application is extreme ly complex, difficult to read, it is not easy reuse, but also for future maintenance and modification will also c ause difficulties. In fact, CSDN the JSP / Servlet forum, can often see some questions, the code is very long, c an logic is not very clear, a large number of HTML and Java code mixed together. This is the random development of the defects.Early dynamic pages mainly CGI (Common Gateway Interfac e, public Gateway Interface) technology, you can use diffe rent languages of the CGI programs, such as VB, C / C + + or Delphi, and so on. Though the technology of CGI is developed and powerful, because of difficulties in pr ogramming, and low efficiency, modify complex shortcomings, it is gradually being replaced by the trend. Of all th e new technology, JSP / Servlet with more efficient and easy to program, more powerful, more secure and has a go od portability, they have been many people believe that t he future is the most dynamic site of the future develop ment of technology.Similar to CGI, Servlet support request / response mod el. When a customer submit a request to the server, 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 the customer. And the CGI is different, Servlet not generate a new process, but with HTTP Server at the same proces s. It threads through the use of technology, reduce the server costs. Servlet handling of the request process is this: When received from the client's request, calling ser vice 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 complex, in fact, simply said to Serv let is a Java class. And the general category of the di fference is that this type operating in a Servlet contain er, which can provide session management and targeted life cycle 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 datab ase and crossplatform capability. Moreover, Servlet using t hread, and can develop more efficient Web applications.JSP technology is a key J2EE technology, it at a hig her level of abstraction of a Servlet. It allows conventi onal static and dynamic HTML content generated by combinin g an HTML page looks like, but as a Servlet to run. Th ere are many commercial application server support JSP tec hnology, such as BEA WebLogic, IBM WebSphere, JRun, and s o 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 compile, do not have to pack, do not have to ClassPath settings, you can visit as ordinary W eb It did visit, the server will automatically help you to do other work.JSP document looks like an ordinary static HTML docume nt, 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 compiler, and then, like other Servlet, from Servlet engine to ha ndle. Servlet engine of this type loading, handling requests from customers, and the results returned to the custom er.After another visit this page to the customer, as lon g as the paper there have been no changes, JSP engine h as been loaded directly call the Servlet. If you have al ready been modified, it will be once again the implementa tion of the above process, translate, compile and load. I n fact, this is the so-called "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 acces s to all the information about the request, the session, and the application. combining JSP with servlets lets yo u clearly separate the application logic from the presenta tion of the application; in other words, 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 that extends a server with functionality for processing a request and producing a r esponse. It's implemented using the classes and interfaces defined by the Servlet API. The API consists of two pa ckages: the javax.servlet package contains classes and inte rfaces that are protocolindependent, while the javax.servlet .http package provides HTTP-specific extensions and utility classes.What makes a servlet a servlet is that the class imp lements an interface named javax.servlet.Servlet, either dir ectly or by extending one of the support classes. This i nterface defines the methods used by the web container to manage and interact with theservlet. A servlet for processing HTTP requests typically extends thejavax.servlet.http.HttpServlet class. This class implements the Servlet interface and provides additional methods suita ble for HTTP processing.Servlet LifecycleThe web container manages all aspects of the servlet's l ifecycle. It creates an instance of the servlet class whe n needed, passes requests to the instance for processing, and eventually removes the instance. For an HttpServlet, the container calls the following methods at the appropr iate times in the servlet lifecycle.Besides the doGet( ) and doPost( ) methods, there are m ethods corresponding to the other HTTP methods: doDelete( ), doHead( ), doOptions( ), doPut( ), and doTrace( ). Ty pically you don't implement these methods; the HttpServle t class already takes care of HEAD, OPTIONS, and TRACE r equests in a way that's suitable for most servlets, and the DELETE and PUT HTTP methods are rarely used in a we b application.It's important to realize that the container creates o nly one instance of each servlet. This means that the se rvlet must be thread safe - able to handle multiple requ ests at the same time, each executing as a separate thre ad through the servlet code. Without getting lost in deta ils, you satisfy this requirement with regards to instance variables if you modify the referenced objects only in the init( ) and destroy( ) methods, and just 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 Servlet API classes in the CLASSPATH environment variable. The JAR file is dist ributed with all web containers. Tomcat includes it in a file called servlet.jar, located in the common/lib direct ory. On a Windows platform, you include the JAR file in the CLASSPATH.Reading a RequestOne of the arguments passed to the doGet( ) and doPo st( ) methods is an object that implements the HttpServle tRequest interface. This interface defines methods that pro vide access to a wealth of information about the request.Generating a ResponseBesides the request object, the container passes an objec t that implements the HttpServletResponse interface as an argument to the doGet( ) and doPost( ) methods. This int erface defines methods for getting a writer or stream for the response body. It also defines methods for setting the response status code and headers.Using Filters and ListenersThe servlet specification defines two component types besi de servlets: filters and listeners. These two types were introduced in the Servlet 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 a component that can intercept a requesttargeted for a servlet, JSP page, or static page, as well as the response before it's sent to the client. This makes it easy to centralize tasks that apply to all re quests, such as access control, logging, and charging for the content or the services offered by the application.A filter has full access to the body and headers of t he request and response, so it can also perform various transformations. One example is compressing the response bo dy if the Acceptlanguage request header indicates that th e client can handle a compressed response.A filter can be applied to either a specific servlet or to all requests matching a URL pattern, such as URL s starting with the same path elements or having the sam e extension.ListenersListeners allow your application to react to certain e vents. Prior to Servlet 2.3, you could handle only sessio n attribute binding events (triggered when an object was added or removed from a session). You could do this by letting the object saved as a sessionattributimplement the HttpSessionBindingListener interface. With the new interfa ces introduced in the 2.3 version of the specification, y ou can create listeners for servlet context and session l ifecycle events as well as session activation and passivat ion events (used by a container that temporarily saves se ssion state to disk or migrates a session to another ser ver). A newsession attribute event listener also makes it possible to deal with attribute binding events for all sessions in one place, instead of placing individual liste ner objects in each session.The new types of listeners follow the standard Java e vent model. 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 lis tener class is registered with the container when the app lication starts, and the container then calls the event m ethods at the appropriate times.Initializing Shared Resources Using a ListenerBeans like this typically need to be initialized befor e they can be used. Forinstance, they may need a reference to a database or some other external data source and may create an initi al information cache in memory to provide fast access eve n to the first request for data. You can include code f or initialization of the shared resources in the servlet and JSP pages that need them, but a more modular approac h is to place all this code in one place and let the other parts of the application work on the assumption tha t the resources are already initialized and available. An application lifecycle listener is a perfect tool for thi s type of resource initialization. This type of listener implements the javax.servlet.ServletContextListener interface , with methods called by the container when the applicati on starts and when it shuts down.Picking the Right Component Type for Each TaskThe Project Billboard application introduced is a fairl y complex application. Half the pages 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 contain even more pages, for instance, pages for access to a shared document arc hive, time schedules, and a set of pages for administrati on. As the application evolves, it may become hard to ma intain as a pure JSP application. It's easy to forget to include the access control code in new pages.This is clearly an application 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 main requirements and see how we can map them to appropriate component types:Database access should be abstracted, to avoid knowledg e of a specific dataschema or database engine in more than one part of the application: beans in the role of Model can be used to accomplish this.The database access beans must be made available to a ll other parts of theapplication when it starts: an application lifecycle event listener is the perfect component type for this task.Only authenticated users must be allowed to use the appli cation: a filter canperform access control to satisfy this requirement.Request processing is best done with Java code: a servlet, acting as the Controller fits the bill.It must be easy to change the presentation: this is where JSP shines, acting as the View.Adding servlets, listeners, and filters to the mix m inimizes the need for complex logic in the JSP pages. Pl acing all this code in Java classes instead makes it pos sible to use a regular Java compiler and debugger to fix potential problems.Centralized Request Processing Using a ServletWith a servlet as the common entry point for all a pplication requests, you gain control over the page flowof the application. The servlet can decide which type of response to generate depending on the outcome of the requested action, such as returning a common error page for all requests that fail, or different responses depending on the type of client making the request. With the hel p from some utility classes, it can also provide services such as input validation, I18N preparations, and in gene ral, encourage a more streamlined approach to request hand ling.Mapping Application Requests to the ServletThe first requirement for using a Controller servlet is that all requests must pass through it. This can be satisfied in many ways. If you have played around a bi t with servlets previously, you're probably used to invoki ng a servlet with a URI that starts with /myApp/servlet. This is a convention introduced by Suns Java Web Server (JWS), the first product to support servlets before the API was standardized. Most servlet containers support thi s convention today, even though it's not formally defined in the servlet specification.。

JSP及其WEB技术中英文对照外文翻译文献

JSP及其WEB技术中英文对照外文翻译文献

中英文对照外文翻译文献(文档含英文原文和中文翻译)JSP and WEB technolog1 JSP IntroductionJSP (JavaServer Pages) is a Java-based scripting technology. Is advocated by Sun Microsystems Inc., together with a number of companies involved in the establishment of a dynamic web page technology standards. JSP technology is somewhat similar to ASP technology, It is a traditional HTML page file (*. htm, *. html) to insert Java program segment (Scriptlet) and JSP tag (tag), To form the JSP file(*jsp). Web development with JSP is a cross-platform applications that can run under Linux, but also in other operating systems. In the JSP of the many advantages, one of which is that it will be HTML encoded Web page from the business logic separated effectively. JSP access with reusable components, such as Servlet, JavaBean and Java-based Web applications. JSP also supports directly in the Web page embedded Java code. JSP can be used two ways to access documents: JSP documents sent by the browser request, the request sent to the Servlet. JSP technology uses Java programming language, XML-type tags and scriptlets, to have a package deal with the logic of dynamic pages. Page tags and scriptlets can also exist in the server access to the resources of the application logic. JSP logic and Web page design and display isolated and support reusable component-based design, Web-based applications more quickly and easily developed.The Web server when meets visits the JSP homepage the request, first carries out segment, will then carry out the result code to return together with JSP in the document HTML for the customer. The insertion Java segment may operate the database, again the directional homepage and so on, realizes the function which the establishment dynamic homepage needs. JSP and Java Servlet are the same, is in the server end execution, usually returns to this client side is a HTML text, therefore client side, so long as has the browser to be able to glance over.The JSP page is composed of the HTML code and the inserting Java code. The server in the page by the client side was requested that later will carry on processing to these Java code, will then produce the HTML page will return gives the client side the browser. Java Servlet is the JSP technology base, moreover the large-scale Web applicationprocedure's development needs Java Servlet and the JSP coordination can complete. JSP had the Java technology simply easy to use, complete object-oriented, had the platform independency, and safe reliable, mainly faced Internet's all characteristics.2 JSP computing techniqueTo carry on the dynamic website conveniently fast the development, JSP has made the improvement in the following several aspects, causes it to become builds the cross platform fast the dynamic website first choice plan.2.1 carries on the content production and the demonstration separatesWith the JSP technology, the Web page development personnel may use HTML or the XML marking design and the formatted final page, and uses the JSP marking or the tootsy produces on page's dynamic content originally. Production content's logic is sealed in marks and in the JavaBeans module, and ties up in the script, all scripts in server end movement. Because core logic is sealed in marks and in JavaBeans, therefore the Web administrative personnels and the page designer, can edit and use the JSP page, but does not affect the content the production. In the server end, the JSP engine explained that the JSP marking and the script, produce the content which requested, and (or XML) page's form transmits the result by HTML the browser. This both are helpful in the author protects own code, and can guarantee any based on the HTML Web browser's complete usability.2.2 may entrust with heavy responsibility the moduleThe overwhelming majority JSP page relies on may entrust with heavy responsibility, the cross platform module (JavaBeans or Enterprise the JavaBeans module) carries out complex processing which the application procedure requests. The development personnel can share and exchange the execution ordinary operation the module, or causes these modules uses for more users and the customer association. Has accelerated the overall development process based on module's method, and causes each kind of organization obtains balanced in their existing skill and in the optimized result development endeavor.2.3 uses markingThe Web page development personnel will not be the familiar script language programmers. The JSP technology has sealed many functions, these functions are easy touse, marking to carry on the dynamic content production with JSP in the related XML to need. The standard JSP marking can visit and the instantiation JavaBeans module, the establishment or the retrieval module attribute, downloads Applet, as well as the execution difficulty with codes and the time-consuming function with other methods.2.4 adapts the platformNearly all platforms support Java, JSP+JavaBeans to be possible to pass unimpeded nearly under all platforms. Transplants from a platform to other platform, JSP and JavaBeans does not even need to translate, because the Java byte code is standard has nothing to do with the platform.2.5 database connectionIn Java connects the database the technology is the JDBC, Java procedure is connected through the JDBC driver and the database, operations and so on execution inquiry, extraction data. Sun Corporation has also developed JDBC-ODBC bridge, uses this technical Java procedure to be possible to visit has the ODBC driver database, at present the majority database systems have the ODBC driver, therefore the Java procedure can visit such as Oracle, Sybase, MS SQL Server and databases and so on MS Access. In addition, through the development marking storehouse, the JSP technology may further expand. The third party development personnel and other personnel may found their marking storehouse for the commonly used function. This enables the Web page development personnel to be able to use the familiar tool and to be similar to marking same carries out the specific function component to carry on the work. The JSP technology very easy conformity to many kinds of application architecture, to use the extant tool and the skill, and can expand to the support enterprise distributional application.3 Eclipse function synopsisMore and more Java development personnel already started the productivity which and the quality income appreciates Eclipse JDT to provide. It was the Java editor provides grammar Gao Liang to demonstrate that the formatting, the fold, the content were auxiliary, code template and so on many functions. It grows unceasingly available restructuring and the code generation function set permits you in a higher rank the operation code, and automated usual code intensity duty and easy wrong duty. Moreover, in develops the codeand uses JDT to compile and to carry out the JUnit test built-in support carries on the unit testing after the code, may use Eclipse the first-class Java debugger debugging when the movement meets any question. Besides JDT, Eclipse SDK- the most popular downloading - also contains Plug-in Development Environment(PDE). PDE used the specific function to expand JDT to construct the Eclipse plug-in unit - based on the Eclipse application procedure basic construction agglomeration. In fact, uses the tool which provides by Eclipse itself to be able to surmount the Java development, may expand the existing Eclipse application procedure, or even founds the brand-new application procedure.Eclipse by a script level constitution, contains in many functional modules or the Eclipse terminology so-called “the plug-in unit”. The plug-in unit is provides all functions in the Eclipse application procedure the module. They cooperate through its API to pay the final outcome together. In Eclipse, even the most foundation's function, for instance the search and the start installment's plug-in unit, seals in the plug-in unit. In order to expand the existing Eclipse function or carry on the construction in above, the plug-in unit the concrete expansion contribution for the expansion spot which will expose by other plug-in units. Usually, the plug-in unit concentrates the specific region responsibility, and gives through or a many expansion way other responsibility designation other plug-in units. For example, a plug-in unit allows you parallel to compare two documents visibly the contents, but it will not care how to read these documents even how to explain these document structure; This is other plug-in unit's work. When compared with two documents, this plug-in unit first inspects whether to have another plug-in unit to be possible to explain these document structure. If found one, it to the plug-in unit inquiry related file organization information which found, and used this information in the comparison process.May see that the modular construction was Eclipse has provided the huge flexibility, and provided one to be possible to support the massive application procedure platform which the original design has not expected.4 Structs function synopsisStruts is a MVC frame (Framework), uses in developing Java fast the Web application. Struts realizes the key point in C(Controller), Action which and we have custom-madeincluding ActionServlet/RequestProcessor, was also V(View) provides a series of rows to have custom-made the label (Custom Tag). Spring is a light vessel (light-weight container), its core is the Bean factory (Bean Factory), with constructs M(Model) which we need. Above this foundation, Spring has provided AOP (Aspect-Oriented Programming, face stratification plane programming) realization, provides under the non-management environment with it to declare services and so on way business, security; Is more convenient to Bean factory expansion ApplicationContext we to realize the J2EE application; DAO/ORM realizes facilitates us to carry on the database the development; Web MVC and Spring Web have provided Java the Web application frame or carries on the integration with other popular Web frame. That is may a both use, achieve both own characteristic carries on supplementary.Structs is the kind which, servlet and the JSP mark a group cooperates mutually, they compose the MVC 2 designs which may entrust with heavy responsibility. This definition expressed that Struts is a frame, but is not a storehouse, but Struts has also contained the rich mark storehouse and the independence in this frame work utility program class.Client browser (customer browser), the request founds an event from customer browser's each HTTP. The Web vessel will use a HTTP response to make the response.Controller (controller), the controller receive from browser's request, and decided that sends out where this request. Speaking of Struts, the controller is an order design pattern which realizes by servlet. struts-config.xml document disposition controller.Service logic, the service logic renewal model's condition, and helps the control application procedure the flow. Speaking of Struts, this is through takes the actual service logic “thin” the packing Action kind to complete.Model (model) condition, model expression application procedure condition. Service object renewal application procedure condition. ActionForm bean in conversation level or request level expression model condition, but is not in the lasting level. The JSP document uses JSP to mark the read from the ActionForm bean information.View (view), the view is a JSP document. And does not have the flow logic, does not have the service logic, also does not have the model information -- Only then marks. The mark causes Struts is different with other frames (for example Velocity) one of factors.Just like the Struts controller is (event usually is HTTP post) maps the event kind of servlet. you to expect - the air-operated controller use configuration files to cause you notto need to carry on to these values the hard code. The time has changed, but method as before.The Action kind, ActionForm maintains the Web application procedure the conversation condition. ActionForm is one abstract class, must found this kind of subclass for each input form model. When I said when input form model, what refers to the ActionForm expression is establishes or in the renewal general sense data by the HTML form.The Action kind is service logic packing. A Action kind of use is transforms HttpServletRequest into the service logic. Must use Action, please found its subclass and covers process () the method.ActionServlet (Command) will use perform () the method the parametrization kind to transmit for ActionForm. Still did not have too many repugnant request.getParameter () to transfer. When the event progresses to this step, the input form data (or HTML form data) has been withdrawn from the request class and shifts to the ActionForm kind.Considered that a Action kind of another way is the Adapter design pattern. The Action use will be “a kind of connection will transform another connection which will need for the client. Adapter enables the kind the joint operation, if does not have Adapter, then these kinds will be unable because of the incompatible connection the joint operation.”. In this example's client is ActionServlet, it knows nothing about to our concrete service class connection. Therefore, Struts has provided a service connection which it can understand, namely Action. Through expands Action, we cause our service connection and the Struts service connection maintain compatible.5 CSS synopsisThe CSS edition method is the same with HTML, may also be any text editor or the homepage edition software, but also has uses for to edit CSS specially the software. If you write the CSS sentence regards the exterior cascading style sheet, but transfers in the HTML document, then its extension saves .css to be possible. Initially the technical personnel found out HTML, mainly stresses on the definition content, for instance expressed that a paragraph, indicates the title, but excessively has not designed HTML the typesetting and the contact surface effect.Along with the Internet rapid development, HTML is widely applied, the surfer people hoped certainly that the homepage makes attractive, therefore the HTMLtypesetting and the contact surface effect's limitation exposes day by day. In order to solve this problem, the people also took many tortuous paths, has used some not good method, for instance increases many attribute results to HTML becomes the code very extremely fat, turns the picture the text, excessively many comes the typesetting using Table, expresses the white space with the blank picture and so on. Appears until CSS.CSS may be a homepage design breakthrough, it has solved the homepage contact surface typesetting difficult problem. May such say that HTML Tag is mainly defines the homepage content (Content), but CSS decided how these homepage content does demonstrate (Layout). The CSS English is Cascading Style Sheets, Chinese may translate the tandem cascading style sheet. CSS may divide into three kinds according to its position: In inlays the style (Inline Style), internal cascading style sheet (Internal Style Sheet), exterior cascading style sheet (External Style Sheet).6 HTML function synopsisHyper Text Markup the Language hypertext mark language is one kind uses for to manufacture the hypertext documents the simple mark language. The hypertext documents which compiles with HTML are called the HTML documents, it can the independence in each kind of operating system platform (for example UNIX, WINDOWS and so on). HTML has served as since 1990 on World Wide Web the information to express the language, uses in describing the Homepage form design and it and on WWW the other Homepage linked information.The HTML documents (i.e. the Homepage source document) was one has laid aside the mark ASCII text document, usually it had .html or the .htm document extension. Produces HTML documents mainly to have the following three ways: 1. the manual direct compilation (e.g. ASCII text editor which or other HTML edition tool likes with you). 2. will have other form documents through certain format conversion tool (for example the WORD documents) to transform the HTML documents. 3. by the Web server (or said that the HTTP server) one only then real-time dynamic produces. the HTML language is through uses each kind of mark (tags) to mark the documents the structure as well as marks the ultra chain (Hyperlink) the information.Although the HTML language described the documents structure form, but how can't define the documents information to precisely demonstrate and arrange, but is onlysuggested how the Web browser (for example Mosiac, Netscape and so on) should demonstrate and arrange these information, is decided finally in front of user's demonstration result by the Web browser's demonstration style and to the mark explanatory ability. Why is the identical documents the effect which demonstrated in the different browser meets is dissimilar. At present the HTML language's edition is 2.0, it is based on SGML (Standard Generalized Markup Language, standard sets at sign language generally, as soon as is applies mechanically describes digitized documents structure and manages its content complex standard) a subset to evolve comes. Although in next edition's standard HTML3.0 (is also called HTML+) to draw up, but some the partial experimental nature draft standard widely has been used, the mostly outstanding Web browser (for example Netscape and so on) can explain in the HTML3.0 part new mark, therefore introduced in this chapter some HTML3.0 new mark has been accepted by the most browsers.7 Js script language synopsisJS is javascrip, Javascript is one kind 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 question. 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 confirmation 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 is “ECMAScript”. This s tandard by ECMA organization development and maintenance. ECMA-262 is the official JavaScript standard. This standard based on JavaScript (Netscape) and JScript (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 ECMA-262 development began in 1996, in 1997 July, the ECMA general meeting has accepted its first edition.Script script uses one specific descriptive language, rests on certain 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 application 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 and 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 the homepage the E-mail address can transfer Outlook Express or the Foxmail this kind of mail software automatically, is realizes through the script function. Also because 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, 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 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 use script easily. Through “the safe establishment” the dialog box, the choice “the script” under option each kind of estab lishment may with ease realize to script being forbid and begins using.Present's script language is quite many, script language execution generally only with concrete explanation actuator related, so long as therefore on the system has the corresponding language interpreter to be possible to achieve the cross platform. Script (Script), is includes order and so on bind and alias sets, you may save this set are an independent document then in the time which needs carries out, like this may facilitate you in the CS use. The script may save for the suffix named .cfg document places under the cstrike folder, when execution in control bench input: exec (script filename) .cfg then. For instance saves a script is the buys.cfg document, inputs in the control bench: execbuys.cfg may realize the function which we need. Must realize an order, so long as is good this process definition (alias), and assigns a key position for this order, so long as later according to will assign the good key position, may realize this proceJSP及其WEB技术. 1 JSP简介JSP(JavaServer Pages)是一种基于Java的脚本技术。

JSP技术外文文献

JSP技术外文文献

JSP and WEB technologyKathy Sierra, Bert Bates1 JSP IntroductionJSP (JavaServer Pages) is a Java-based scripting technology. Is advocated by Sun Microsystems Inc., together with a number of companies involved in the establishment of a dynamic web page technology standards. JSP technology is somewhat similar to ASP technology, It is a traditional HTML p age file (*. htm, *. html) to insert Java program segment (Scriptlet) and JSP tag (tag), To form the JSP file(*jsp). Web development with JSP is a cross-platform applications that can run under Linux, but also in other operating systems. In the JSP of the many advantages, one of which is that it will be HTML encoded Web page from the business logic separated effectively. JSP access with reusable components, such as Servlet, JavaBean and Java-based Web applications. JSP also supports directly in the Web page embedded Java code. JSP can be used two ways to access documents: JSP documents sent by the browser request, the request sent to the Servlet. JSP technology uses Java programming language, XML-type tags and scriptlets, to have a package deal with the logi c of dynamic pages. Page tags and scriptlets can also exist in the server access to the resources of the application logic. JSP logic and We b page design and display isolated and support reusable component-based design, Web-based applications more quickly and easily developed.The Web server when meets visits the JSP homepage the request, first carries out segment, will then carry out the result code to return together with JSP in the document HTML for the customer. The insertion Java segment may operate t he database, again the directional homepage and so on, realizes the function which the establishment dynamic homepage needs. JSP and Java Servlet are the same, is in the server end execution, usually returns to this client side is a HTML text, therefore client side, so long as has the browser to be able to glance over.The JSP page is composed of the HTML code and the inserting Java code. The server in the page by the client side was requested that later will carry on processing to these Java code, will then produce the HTML page will return gives the client side the browser. Java Servlet is the JSP technology base, moreover the large-scale Web application procedure's development needs Java Servlet and the JSP coordination can complete. JSP had the Java technology simply easy to use, completeobject-oriented, had the platform independency, and safe reliable, mainly faced Internet's all characteristics.2 JSP computing techniqueTo carry on the dynamic website conveniently fast the development, JSP has made the improvement in the following several aspects, causes it to become builds the cross platform fast the dynamic website first choice plan.2.1 carries on the content production and the demonstration separatesWith the JSP technology, the Web page develop ment personnel may use HTML or the XML marking design and the formatted final page, and uses the JSP marking or the tootsy produces on page's dynamic content originally. Production content's logic is sealed in marks and in the JavaBeans module, and ties up in the script, all scripts in server end movement. Because core logic is sealed in marks and in JavaBeans, therefore the Web administrative personnels and the page designer, can edit and use the JSP page, but does not affect the content the production. In the server end, the JSP engine explained that the JSP marking and the script, produce the content which requested, and (or XML) page's form transmits the result by HTML the browser. This both are helpful in the author protects own code, and can guarantee any based on the HTML Web browser's complete usability.2.2 may entrust with heavy responsibility the moduleThe overwhelming majority JSP page relies on may entrust with heavy responsibility, the cross platform module (JavaBeans or Enterprise the JavaBea ns module) carries out complex processing which the application procedure requests. The development personnel can share and exchange the execution ordinary operation the module, or causes these modules uses for more users and the customer association. Has accelerated the overall development process based on module's method, and causes each kind of organization obtains balanced in their existing skill and in the optimized result development endeavor.2.3 uses markingThe Web page development personnel will not be the familiar script language programmers. The JSP technology has sealed many functions, these functions are easy to use, marking to carry on the dynamic content production with JSP in the related XML to need. The standard JSP marking can visit and t he instantiation JavaBeans module, the establishment or the retrieval module attribute, downloads Applet, as well as the execution difficulty with codes and the time-consuming function with other methods.2.4 adapts the platformNearly all platforms support Java, JSP+JavaBeans to be possible to pass unimpeded nearly under all platforms. Transplants from a platform to other platform, JSP and JavaBeans does not even need to translate, because the Java byte code is standard has nothing to do with the platform.2.5 database connectionIn Java connects the database the technology is the JDBC, Java procedure is connected through the JDBC driver and the database, operations and so on execution inquiry, extraction data. Sun Corporation has also developed JDBC-ODBC bridge, uses this technical Java procedure to be possible to visit has the ODBC driver database, at present the majority database systems have the ODBC driver, therefore the Java procedure can visit such as Oracle, Sybase, MS SQL Server and databases and so on MS Access. In addition, through the development marking storehouse, the JSP technology may further expand. The third party development personnel and other personnel may found their marking storehouse for the commonly used function. This enables the Web page development personnel to be able to use the familiar tool and to be similar to marking same carries out the specific function component to carry on the work. The JSP technology very easy conformity to many kinds of application architecture, to use the extant tool and the skill, and can expand to the support enterprise distributional application.3 Eclipse function synopsisMore and more Java development personnel already started the productivity which and the quality income appreciates Eclipse JDT to provide. It was the Java editor provides grammar Gao Liang to demonstrate that the formatting, the fold, the content were auxiliary, code template and so on many functions. It grows unceasingly available restructuring and the code generation function se t permits you in a higher rank the operation code, and automated usual code intensity duty and easy wrong duty. Moreover, in develops the code and uses JDT to compile and to carry out the JUnit test built-in support carries on the unit testing after the co de, may use Eclipse the first-class Java debugger debugging when the movement meets any question. Besides JDT, Eclipse SDK- the most popular downloading - also contains Plug-in Development Environment(PDE). PDE used the specific function to expand JDT to construct the Eclipse plug-in unit - based on the Eclipse application procedure basic construction agglomeration. In fact, uses the tool which provides by Eclipse itself to be able to surmount the Java development, may expand the existing Eclipse application procedure, or even founds the brand-new application procedure.Eclipse by a script level constitution, contains in many functional modules or the Eclipse terminology so-called “the plug-in unit”. The plug-in unit is provides all functions in the Eclipse application procedure the module. They cooperate through its API to pay the final outcome together. In Eclipse, even the most foundation's function, for instance the search and the start installment's plug-in unit, seals in the plug-in unit. In order to expand the existing Eclipse function or carry on the construction in above, the plug-in unit the concrete expansion contribution for the expansion spot which will expose by other plug-in units. Usually, the plug-in unit concentrates the specific region responsibility, and gives through or a many expansion way other responsibility designation other plug-in units. For example, aplug-in unit allows you parallel to compare two documents visibly the contents, but it will not care how to read these do cuments even how to explain these document structure; This is other plug-in unit's work. When compared with two documents, this plug-in unit first inspects whether to have another plug-in unit to be possible to explain these document structure. If found one, it to the plug-in unit inquiry related file organization information which found, and used this information in the comparison process.May see that the modular construction was Eclipse has provided the huge flexibility, and provided one to be possible to support the massive application procedure platform which the original design has not expected.4 Structs function synopsisStruts is a MVC frame (Framework), uses in developing Java fast the Web application. Struts realizes the key point in C(Controlle r), Action which and we have custom-made including ActionServlet/RequestProcessor, was also V(View) provides a series of rows to have custom-made the label (Custom Tag). Spring is a light vessel (light-weight container), its core is the Bean factory (Bean Factory), with constructs M(Model) which we need. Above this foundation, Spring has provided AOP (Aspect-Oriented Programming, face stratification plane programming) realization, provides under the non-management environment with it to declare services and so on way business, security; Is more convenient to Bean factory expansion ApplicationContext we to realize the J2EE application; DAO/ORM realizes facilitates us to carry on the database the development; Web MVC and Spring Web have provided Java the Web application frame or carries on the integration with other popular Web frame. That is may a both use, achieve both own characteristic carries on supplementary.Structs is the kind which, servlet and the JSP mark a group cooperates mutually, they compose the MVC 2 designs which may entrust with heavy responsibility. This definition expressed that Struts is a frame, but is not a storehouse, but Struts has also contained the rich mark storehouse and the independence in this frame work utility program class.Client browser (customer browser), the request founds an event from customer browser's each HTTP. The Web vessel will use a HTTP response to make the response.Controller (controller), the controller receive from browser's request, and decided that sends out where this request. Speaking of Struts, the controller is an order design pattern which realizes by servlet. struts-config.xml document disposition controller.Service logic, the service logic renewal model's condition, and helps the control application procedure the flow. Speaking of Struts, this is through takes the actual service logic “thin” the packing Action kind to complete.Model (model) condition, model expression application procedure condition. Service object renewal application procedure c ondition. ActionForm bean inconversation level or request level expression model condition, but is not in the lasting level. The JSP document uses JSP to mark the read from the ActionForm bean information.View (view), the view is a JSP document. And doe s not have the flow logic, does not have the service logic, also does not have the model information -- Only then marks. The mark causes Struts is different with other frames (for example Velocity) one of factors.Just like the Struts controller is (event usually is HTTP post) maps the event kind of servlet. you to expect - the air-operated controller use configuration files to cause you not to need to carry on to these values the hard code. The time has changed, but method as before.The Action kind, ActionForm maintains the Web application procedure the conversation condition. ActionForm is one abstract class, must found this kind of subclass for each input form model. When I said when input form model, what refers to the ActionForm expression is establi shes or in the renewal general sense data by the HTML form.The Action kind is service logic packing. A Action kind of use is transforms HttpServletRequest into the service logic. Must use Action, please found its subclass and covers process () the method.ActionServlet (Command) will use perform () the method the parametrization kind to transmit for ActionForm. Still did not have too many repugnantrequest.getParameter () to transfer. When the event progresses to this step, the input form data (or HTML form data) has been withdrawn from the request class and shifts to the ActionForm kind.Considered that a Action kind of another way is the Adapter design pattern. The Action use will be “a kind of connection will transform another connection which will need for the client. Adapter enables the kind the joint operation, if does not have Adapter, then these kinds will be unable because of the incompatible connection the joint operation. In this example's client is ActionServlet, it knows nothing about to our concrete service class connection. Therefore, Struts has provided a service connection which it can understand, namely Action. Through expands Action, we cause our service connection and the Struts service connection maintain compatible.5 CSS synopsisThe CSS edition method is the same with HTML, may also be any text editor or the homepage edition software, but also has uses for to edit CSS specially the software. If you write the CSS sentence regards the exterior cascading style sheet, but transfers in the HTML document, then its extension saves .css to be possible. Initially the technical personnel found out HTML, mainly stresses on the definition content, for instance expressed that a paragraph, indicates the title, but excessively has not designed HTML the typesetting and the contact surface effect.Along with the Internet rapid development, HTML is widely applied, the surfer people hoped certainly that the homepage makes attractive, therefore the HTMLtypesetting and the contact surface effect's limitat ion exposes day by day. In order to solve this problem, the people also took many tortuous paths, has used some not good method, for instance increases many attribute results to HTML becomes the code very extremely fat, turns the picture the text, excessiv ely many comes the typesetting using Table, expresses the white space with the blank picture and so on. Appears until CSS.CSS may be a homepage design breakthrough, it has solved the homepage contact surface typesetting difficult problem. May such say th at HTML Tag is mainly defines the homepage content (Content), but CSS decided how these homepage content does demonstrate (Layout). The CSS English is Cascading Style Sheets, Chinese may translate the tandem cascading style sheet. CSS may divide into three kinds according to its position: In inlays the style (Inline Style), internal cascading style sheet (Internal Style Sheet), exterior cascading style sheet (External Style Sheet).6 HTML function synopsisHyper Text Markup the Language hypertext mark language is one kind uses for to manufacture the hypertext documents the simple mark language. The hypertext documents which compiles with HTML are called the HTML documents, it can the independence in each kind of operating system platform (for example UNIX, WINDOWS and so on). HTML has served as since 1990 on World Wide Web the information to express the language, uses in describing the Homepage form design and it and on WWW the other Homepage linked information.The HTML documents (i.e. the Homepage source document) was one has laid aside the mark ASCII text document, usually it had .html or the .htm document extension. Produces HTML documents mainly to have the following three ways: 1. the manual direct compilation (e.g. ASCII text editor which or other HTM L edition tool likes with you). 2. will have other form documents through certain format conversion tool (for example the WORD documents) to transform the HTML documents. 3. by the Web server (or said that the HTTP server) one only thenreal-time dynamic produces. the HTML language is through uses each kind of mark (tags) to mark the documents the structure as well as marks the ultra chain (Hyperlink) the information.Although the HTML language described the documents structure form, but how can't define the documents information to precisely demonstrate and arrange, but is only suggested how the Web browser (for example Mosiac, Netscape and so on) should demonstrate and arrange these information, is decided finally in front of user's demonstration result b y the Web browser's demonstration style and to the mark explanatory ability. Why is the identical documents the effect which demonstrated in the different browser meets is dissimilar. At present the HTML language's edition is 2.0, it is based on SGML (Stan dard Generalized Markup Language, standard sets at sign language generally, as soon as is applies mechanically describes digitized documents structure and manages its contentcomplex standard) a subset to evolve comes. Although in next edition's standard HTML3.0 (is also called HTML+) to draw up, but some the partial experimental nature draft standard widely has been used, the mostly outstanding Web browser (for example Netscape and so on) can explain in the HTML3.0 part new mark, therefore introduced in this chapter some HTML3.0 new mark has been accepted by the most browsers.7 Js script language synopsisJS is javascrip, Javascript is one kind 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 question. At that time served the end t o need to carry on the confirmation to the data, because the network speed was quite slow, only then 28.8kbps, the confirmation 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 is “ECMAScript”. This standard by ECMA organization development and maintenance. ECMA-262 is the official JavaScript standard. This standard based on JavaScript (Netscape) and JScript (Microsoft). Netscape (Navigator 2.0) Brendan Eich has invented this language, started from 1996, already appeared in all Netscape and in the Microsoft browser. TheECMA-262 development be gan in 1996, in 1997 July, the ECMA general meeting has accepted its first edition.Script script uses one specific descriptive language, rests on certain 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 application 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 and 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 the homepage the E-mail address can transfer Outlook Express or the Foxmail this kind of mail software automatically, is realizes through the script function. Also because 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, like this works as the user brows ing homepage, once transfers this kind of script, will then cause the user the system to come under the attack. Therefore the 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 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 being forbid and begins using.Present's script language is quite many, script language execution generallyonly with concrete explanation actuator related, so long as therefore on the system has the corresponding language interpreter to be possible to achieve the crossplatform. Script (Script), is includes order and so on bind and alias sets, you may save this set are an independent document then in the time which needs carries out, like this may facilitate you in the CS use. The script may save for the suffix named .cfg document places under the cstrike folder, when execution in control bench input: exec (script filename) .cfg then. For instance saves a script is the buys.cfg document, inputs in the control bench: execbuys.cfg may realize the function which we need. Must realize an order, so long as is g ood this process definition (alias), and assigns a key position for this order, so long as later according to will assign the good key position, may realize this process. All scripts are realize through this method.。

Web应用中英文对照外文翻译文献

Web应用中英文对照外文翻译文献

Web应用中英文对照外文翻译文献(文档含英文原文和中文翻译)外文:A Comparative Study of Web Application Design ModelsUsing the Java TechnologiesAbstract.The Servlet technology has been the most widely used technology for building scalable Web applications. In the events, there are four design models for developing Web applications using the Java technologies: Model 1, Model2, Struts, and JavaServer Faces (JSF). Model 1 employs a series of JSP pages; Model 2 adopts the Model-View-Controller pattern; Struts is a framework employing the Model 2 design model; and JSF is a new technology that supports ready-to-use components for rapid Web application development. Model 1 is not recommended for medium-sized and large applications as it introduces maintenance nightmare. This paper compares and evaluates the ease of application development and theperformance of the three design models (Model 2, Struts, and JSF) by building three versions of an online store application using each of the three design models, respectively.1 IntroductionToday, Web applications are the most common applications for presenting dynamic contents. There are a number of technologies for building Web applications, the most popular of which is the Servlet technology . This technology gains its popularity from its superiority over other technologies such as CGI and PHP .Servlets are cumbersome to develop, however, because sending HTML tags requires the programmer to compose them into a String object and send this object to the browser. Also, a minor change to the output requires the servlet to be recompiled. To address this issue, Sun Microsystems invented JavaServer Pages (JSP) . JSP allows HTML tags to be intertwined with Java code and each page is translated into a servlet. A JSP page is a servlet. However, compilation occurs automatically when the page is first requested. As a result, changing the output does not need recompilation. In addition, JSP enables the separation of presentation from the business logic through the use of JavaBeans and custom tag libraries. The norm now in developing Javabased Web applications is to use servlets along with JavaServer Pages.In the later development, there are a number of design models for building servlet/JSP applications: Model 1, Model 2, Struts , and JSF . Model 1 and Model 2 were first mentioned in the early specifications of JSP. Model 1 strictly uses JSP pages, with no servlets, and Model 2 uses the combination of both servlets and JSP pages. The terms of Model 1 and Model 2 have been used ever since. Model 1 is suitable for prototypes and very small applications, and Model 2 is the recommended design model for medium sized and large applications.As Model 2 gained more acceptances in the industry, an open source initiative to build the Struts Framework was initiated. Struts perfects Model 2 by providing the controller part of the Model-View-Controller of Model 2. In addition, Struts provides better page navigation management and several custom tag libraries for more rapid development. Despite its steep learning curve and the fact that it wasnever defined in any specification, Struts has been gaining popularity as the alternative to Model 2.JavaServer Faces is built under the Java Community Process under JSR-127.Sun Microsystems proposed this technology in the hope that JSF will be the ultimate model for building Java Web applications. The most important feature of JSF is the availability of ready-to-use components such as extensible UI components, easy page navigation, input validators, data converters and JavaBeans management.The problem facing servlet/JSP programmers are to choose the most appropriate design model. Clearly, JSF provides a better solution in regard to development time. However, some people are not sanguine to adopt this technology for fear of performance penalty due to the overhead of the JSF implementation.We build three versions of an online store application named BuyDirect using Model 2, Struts and JSF. The parameters compared are the number of lines of code, the number of classes, and the performance measurement results. We investigate which of the design models allows the most rapid development process. We evaluate the performances of the applications built upon these models. We provide some suggestions to perfect the existing design models to make development more rapid.The rest of the paper is organised as follows. Section 2 discusses the issues in Web development. Section 3 explains how the three design models address these development issues. Section 4 provides the details of the hardware and software used in these experiments. Section 5 presents the experiment results and analysis. Section 6 reviews the related work. Section 7 concludes by offering some suggestions to improve the existing design models.2 Java Web Development IssuesAll Java Web development uses the Servlet technology as the underlying technology. As such, all Java Web applications have certain issues that need to be addressed:User Interface. The user interface is what the client browser renders as HTMLtags. Any server-side component used in the application must be encoded into the corresponding HTML elements. Besides for displaying the content and data, the user interface is also responsible in receiving input from the user.●Input Validation. User input needs to be validated. There are two types of inputvalidation, server-side and client-side. As the name implies, the server-side input validation is performed on the server after the input reaches the server.Client-side input validation is done on the browser, usually by using JavaScript or other scripting languages. The advantages of using client-side input validation are prompt response and reducing the server workload. The server-side input validation should always be performed regardless the presence of client-side validation because there is no guarantee the user browser's scripting feature is being on and malicious users can easily work around client-side validation.●Model Objects. Model objects in Java-based Web applications are in the formsof JavaBeans. Model objects make up the Model part of the MVC based design model. A model object can be used to bind a component value to be used at a later stage. In addition, it can encapsulate business logic required for processing.●Page Navigation. Almost all Web applications have multiple pages that the usercan navigate from one to another. All MVC-based design models use a servlet as the Controller part. This servlet also acts as the sole entry point to the application. Which page to be displayed after the current request is determined by the value of a specified request parameter. Managing page navigation is critically important.3 Web Application Design ModelsThe Model 2 design model is based on the Model-View-Controller (MVC) design pattern. As explained by Burbeck , there are three main modules in MVC, the Controller, the View, and the Model. The Controller acts as the central entry point to the application. All user interactions go through this controller. The View contains the presentation part of the application, and the Model stores data or encapsulates business logic of the application. In the later development, the StrutsFramework provides a common framework to easily build Model 2 applications. Then, the last initiative is the JavaServer Faces, which also employs the MVC design pattern.In the following sections, we discuss these three design models and explain how each design model addresses the development issues specified in the previous section.3.1 Model 2A Java Web application that is based on the Model 2 design model has one servlet(called the Controller servlet) that serves as the Controller part. All requests are first handled by this servlet, which immediately dispatches the requests to the appropriate views using RequestDispatcher objects. Views in the Model 2 design model are represented by JSP pages. To store data, a Model 2 application uses JavaBeans, which are the Model part of the application. In addition to storing data, the JavaBeans also encapsulate business logic. Each HTTP request carries an action parameter that indicates which view to dispatch this request to. The programmer must code the HTML tags for user interface in all JSP pages in the application and write input validation code. In addition, the model objects are managed by individual JSP pages.3.2 StrutsThe Struts Framework is an improvement of the Model 2 design model. It provides a default Controller servlet so that the user does not have to write and compile one. Struts alleviates the task of page navigation by allowing navigation rules to be present in its application configuration file (an XML document). Changes to the navigation rules do not require recompilation of a Java servlet class. In addition to easier page navigation, Struts provides custom tag libraries that define tags representing HTML elements. One of these tags is used for error handling and Struts is therefore capable of displaying localized error messages in support for internationalization. Struts applications use JavaBeans as their models, just like the Model 2 design model. In addition, Struts programmers have to write their own input validation code.3.3 JSFJSF also employs a controller servlet that is called FacesServlet. This servlet is the only entry point to a JSF application. JSF also uses JSP pages as its views and JavaBeans as its model objects. Unlike Model 2 and Struts, however, JSF provides ready-to-use user interface components that can be written on JSP pages. Upon an invocation of a page of a JSF application, the FacesServlet constructs a component tree that represents the JSP page being requested. Some of the components can also trigger events, making JSF event-driven. For page navigation, JSF uses an approach similar to Struts, i.e., by allowing navigation rules to be defined in an application configuration file (again, an XML document).What distinguishes a JSF application from non-JSF servlet/JSP application is that JSF applications are event-driven. The user interface of a JSF application is one or many JSP pages that host Web components such as forms and input boxes. These components are represented by JSF custom tags and can hold data. A component can be nested inside another, and it is possible to draw a tree of components. Just as in normal servlet/JSP applications, you use JavaBeans to store the data the user entered.4 Function EnvironmentThe software and hardware details for our experiments are described below.4.1 The Servlet ContainerA Java Web application runs in a servlet container, which is the engine that processes the incoming HTTP requests for the resources in the application. For this research project, we use Tomcat, an open source servlet container from the Apache Software Foundation. The version we use is 6.0.Basically, a servlet container processes a servlet by performing the following tasks:- Creating the HttpRequest Object- Creating the HttpResponse Object- Calling the service method of the Servlet interface, passing the HttpRequest and HttpResponse objects.4.2 Testing ClientsFor performance testing, we emulate multiple users using JMeter 1.9 , also from the Apache Software Foundation. JMeter allows the user to choose the number of threads to perform testing. Each thread emulates a different user. JMeter also lets us choose how many times a test will be done. To test a Web application using JMeter, you direct requests to certain IP address, context path, and port number. You can also specify request parameters to be included in each HTTP request. As the output, JMeter notifies the response time of the server in milliseconds for a test. From the response time, we derive the number of hits/seconds the server is capable of serving.4.3 HardwareWe use different computers for running the applications and for testing, so as to obtain maximum performance measurement accuracy. The computer running the application is a XP machine having the following hardware specifications: Intel Core 1GHz CPU with 1G RAM. The computer running the testing clients is a Windows 2000 machine running JMeter. The computer has the following specifications: Intel Core 1GHz CPU with 1G RAM.5 ResultsWe obtain experimental results in two categories: the ease of development and performance. The ease of development category compares the number of classes and the number of lines of code. These numbers indicate how easy it is to develop an application by following a certain design model. An application with the fewer number of classes or the number of lines of code indicates that the application is relatively easier to build. The application with the more number of classes indicates that the application takes more time to develop.The performance measurement results are obtained by comparing two operations. The Search operation is the most common operation in such an application,and the Browse operation.5.1 Ease of Application DevelopmentAs Table 1 shows, it takes the most effort to implement the Model 2 design model. Using Struts alleviates the problem a bit, and the best saving in the development comes if one uses JSF.Table 1. The number of classes and the number of lines for the applications under studyThe Model 2 design model is characterised by the presence of a Controller servlet and a number of JavaBeans classes (as the Model) and JSP pages (as the Views). The Controller servlet is responsible for page navigation rules that employ a series of if statements. Model 2 application programmers must also code for the input validation that in this research is implemented inside a number of custom tag libraries. The other classes in the Model 2 design model are custom tag library and the tag library descriptors responsible for input validation and data display. In fact, input validation takes 590 lines of code, or almost 30% of the total amount of code.In the Struts application, the Controller servlet is provided by the framework, therefore a Struts programmer saves time for not having to write one. However, he/she still needs to write page navigation rules in the Application Configuration file, which is easier than writing a servlet because the Application Configuration file can be edited using a text editor and no compilation is necessary. Input validation must still be done manually, even though the Struts Framework provides an error handling mechanism. The number of classes and the number of lines of code for input validation are almost similar to the Model 2 application. In Struts, the other classes are Action classes to which the default Controller servlet dispatches requests.In JSF input validation comes free through the availability of validatorcomponent. As a result, a JSF application developer can skip this task. In addition, page navigation takes the same course as Struts, i.e. by utilising an Application Configuration file. The other classes in JSF are a ContextListener, an ActionListener, and a Database utility class.5.2 Performance MeasurementFor each operation, we measure the server response time (in milliseconds) for 1 to 10 concurrent users. The number of users is specified by setting the number of threads in Jmeter. Each test is conducted 10 times and the average is taken. Each operation is discussed further is the following sub-sections.5.2.1 Search OperationThe Search operation whose name or description matches the keyword. There is one SQL SELECT statement performed. Figure 2 compares the three versions of applications for the Search operation.Fig. 2. The performance comparison for the Search operation For the Model 2 application, the average server response time for one user is 173 ms and for 10 users is 919 ms. For the Struts application, these numbers are 189 ms and 900 ms, respectively. For the application built using JSF, the average server response time is 210 ms for one user and 932 ms for 10 users. The increase of the response time is proportional to the increase of the number of concurrent users, which means that the server is still able to cope with the load.The Model 2 application has the least overhead, therefore the averageperformance should be better than the Struts and JSF applications. However, the Struts application performs as well as the Model 2 application. This is because the server has enough memory to load all Struts libraries required to run Struts. Also, note that page navigation rules in Struts are loaded and stored in an object called ActionMapping. Therefore, given an action request parameter, the next page of navigation is obtained through a look-up. On the other hand, the Model 2 application uses a series of if statements to find the next page of navigation, given the action request parameter.The JSF application performs slightly worse than the other applications in almost all numbers of concurrent users. This could be due to the time taken by the JSF implementation to construct a component tree for each page requested. However, the difference in server response time between JSF and other applications is not that significant.5.2.2 Browse OperationThe Browse operation,like the Search operation, there is one SQL SELECT statement performed. Figure 3 gives the test results for this operation.Fig. 3. The performance comparison for the Browse operation On average, the Model 2 application performs the best because it has the least overhead. The average server response time is 111 ms for one user and 899 ms for 10 users. The Struts application has comparable performance, with one user average server response time of 180 ms and 10 user response time of 920 ms. The JSF lacks a bit behind the two applications with these numbers being 190 and 1009ms respectively. The increase of the server response time is proportional to the increase of the number of concurrent users, which means the server is able to serve those users well. The average performance measurement results of the Browse operation are very similar to the ones for the Search operation because the database operations of both operations are also similar.6 Related WorkCompare the performance of database-based Web applications using Java servlets, PHP version 3, and Common Gateway Interface (CGI). After a series of benchmark tests that performs data retrieval from a MySQL database, find that the solution of Java servlets with persistent database connection has the best performance. PHP3 using persistent database connections performs fairly well when compared to the CGI solution,also mention the advantages of using Java servlets. According to these authors. Java servlets are an excellent choice to meet the requirement of e-commerce (such as online shopping) applications and are able to handle client requests in a highly interactive mode.Comparing PHP 4, Java servlets, and Enterprise JavaBeans. Measure the performance of these three architectures using two applications. Study reveals that PHP4 is more efficient than Java servlets, and the EJBs perform even worse than servlets. However, note that servlets, being part of the Java solution, provides the flexibility of being able to be ported to another system with a different operating system.7 ConclusionWe find that it is most rapid to build Web applications using JSF. Model 2 applications are the least rapid but give the best performance. Struts applications sit in the middle of the other two design models in both comparisons.We make some suggestions that could improve the Servlets technology in general and enhance the performance of applications based on both design models. Struts. Struts is not based on any specification and there is no documentation that discusses its internal working. Therefore, it is hard to know what have been implemented and what could be improved.●The Servlets Technology. The Servlet 2.3 Specification does not define anycaching mechanism. There is no mention of caching in the upcoming Servlet2.4 Specification either. Despite the dynamic nature of the content of a Webapplication, some contents do not change very often. For example, the categories of products that a user can browse in an online store application probably only change once in a month. If those semi-static contents must be generated from the database every time they are requested, a lot of programming resources will be wasted. Servlet programmers get around the absence of caching by writing an object that caches certain content. However, since there is no standard for caching, many programmers write the same piece of code again and again.●Model 2.The main drawback is that the page navigation rules are hard-coded inthe Controller servlet. This means any minor change to the program flow will require the Controller servlet to be re-compiled. The solution to this problem is to provide a mapper that reads the page navigation rules when the application starts. The code could be conveniently written in the init method of the Controller servlet. This method is only executed once, i.e. the first time the servlet is loaded into memory. If the properties file needs to be re-read every time it changes, the programmer can check the timestamp of the properties file for each request, and compares it with the previous read of this file. If the timestamp is more current than the previous read, the mapper can be re-constructed. This feature can be enabled and disabled by using an initial parameter in the Context object. At the development phase, this feature should be enabled. At deployment, this feature should be off. The use of the properties file to store the page navigation rules also makes it possible to avoid a series of if statements in the Controller Servlet, which can be time-consuming for every request. Instead, a HashMap can be used, with action request parameters as keys and the next JSP pages as values. The other disadvantage of this design model is the absence of standard components for input validation and user interface. However, this has been solved in JSF.●JSF. JSF provides solutions to common problems in Web development, such aspage navigation management, UI components and input validators. However, because this technology is still very young, there are not too many UIcomponents available, forcing programmers to combine JSF with non-JSF servlets/JSP pages. JSF is event-driven. JSF programmers determine the behavior of a JSF application by writing event listeners, just like those listeners in a Swing application. In JSF version 1.0, there are currently two types of events that can be triggered: ActionEvent and ValueChangedEvent. However, this is good enough to provide sufficient level of interactivity between the application and its users. Adding more types of events will definitely make JSF more appealing.References[1].Cecchet, E., Chanda A., Elnikety S., Marguerite J., Zwaenepoel W.: Performance Comparison of Middleware Architectures for Generating Dynamic Web Content. Proceeding of the 4th International Middelware Conference, 2003.[2].Cecchet, E., Marguerite, J., and Zwaenepoel, W.: Performance and Scalability of EJB Applications. Proceedings of OOPSLA’02, 2002.[3].Wu, A., Wang, H., and Wilkins, D.: Performance Comparison of Alternative Solutions for Web-To-Database Applications. Proceedings of the Southern Conference on Computing, the University of Southern Mississippi, 2000.基于Java技术的Web应用设计模型的比较研究摘要Servlet技术在建立可扩展性Web应用中是被应用最广泛的技术。

JSP的技术发展历史 外文文献和翻译资料 中英文对照

JSP的技术发展历史  外文文献和翻译资料 中英文对照

外文资料原文THE TECHNIQUE DEVELOPMENT HISTORY OF JSPThe Java Server Pages( JSP) is a kind of according to web of the script plait distance technique, similar carries the script language of Java in the server of the Netscape company of server- side JavaScript( SSJS) and the Active Server Pages(ASP) of the Microsoft. JSP compares the SSJS and ASP to have better can expand sex, and it is no more exclusive than any factory or some one particular server of Web. Though the norm of JSP is to be draw up by the Sun company of, any factory can carry out the JSP on own system.1.1 GENER ALIZEThe JSP(Java Server Pages) is from the company of Sun Microsystems initiate, the many companies the participate to the build up the together of the a kind the of dynamic the state web the page technique standard, the it have the it in the construction the of the dynamic state the web page the strong but the do not the especially of the function. JSP and the technique of ASP of the Microsoft is very alike. Both all provide the ability that mixes with a certain procedure code and is explain by the language engine to carry out the procedure code in the code of HTML. Underneath we are simple of carry on the introduction to it.JSP pages are translated into servlets. So, fundamentally, any task JSP pages can perform could also be accomplished by servlets. However, this underlying 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 other. After all, anything you can do on a particular computer platform in the Java programming language you could also do in assembly language. But it still matters which you choose.JSP provides the following benefits over servlets alone:• It is easier to write and maintain the HTML. Your static code is ordinary HTML: no extra backslashes, no double quotes, and no lurking Java syntax.• You can use standard Web-site development tools. Even HTML tools that know nothing about JSP can be used because they simply ignore the JSP tags.• 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 large 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.1.2 JSP CHARACTERISTICSIs a service according to the script language in some one language of the statures system this kind of discuss, the JSP should be see make is a kind of script language. However, be a kind of script language, the JSP seemed to be too strong again, almost can use all Javas in the JSP.Be a kind of according to text originally of, take manifestation as the central development technique, the JSP provided all advantages of the Java Servlet, and, when combine with a JavaBeans together, providing a kind of make contents and manifestation that simple way that logic separate. Separate the contents and advantage of logical manifestations is, the personnel who renews the page external appearance need not know the code of Java, and renew the JavaBeans personnel also need not be design the web page of expert in hand, can use to take the page of JavaBeans JSP to define the template of Web, to build up a from have the alike external appearance of the website that page constitute. JavaBeans completes the data to provide, having no code of Java in the template thus, this means that these templates can be written the personnel by a HTML plait to support. Certainly, can also make use of the Java Servlet to control the logic of the website, adjust through the Java Servlet to use the way of the document of JSP to separate website of logic and contents.Generally speaking, in actual engine of JSP, the page of JSP is the edit andtranslate type while carry out, not explain the type of. Explain the dynamic state web page development tool of the type, such as ASP, PHP3 etc., because speed etc. reason, have already can't satisfy current the large electronic commerce needs appliedly, traditional development techniques are all at to edit and translate the executive way change, such as the ASP → ASP+;PHP3 → PHP4.In the JSP norm book, did not request the procedure in the JSP code part( be called the Scriptlet) and must write with the Java definitely. Actually, have some engines of JSP are adoptive other script languages such as the EMAC- Script, etc., but actually this a few script languages also are to set up on the Java, edit and translate for the Servlet to carry out of. Write according to the norm of JSP, have no Scriptlet of relation with Java also is can of, however, mainly lie in the ability and JavaBeans, the Enterprise JavaBeanses because of the JSP strong function to work together, so even is the Scriptlet part not to use the Java, edit and translate of performance code also should is related with Java.1.3 JSP MECHANISMTo comprehend the JSP how unite the technical advantage that above various speak of, come to carry out various result easily, the customer must understand the differentiation of" the module develops for the web page of the center" and" the page develops for the web page of the center" first.The SSJS and ASP are all in several year ago to release, the network of that time is still very young, no one knows to still have in addition to making all business, datas and the expression logic enter the original web page entirely heap what better solve the method. This kind of model that take page as the center studies and gets the very fast development easily. However, along with change of time, the people know that this kind of method is unwell in set up large, the Web that can upgrade applies the procedure. The expression logic write in the script environment was lock in the page, only passing to shear to slice and glue to stick then can drive heavy use. Express the logic to usually mix together with business and the data logics, when this makes bethe procedure member to try to change an external appearance that applies the procedure but do not want to break with its llied business logic, apply the procedure of maintenance be like to walk the similar difficulty on the eggshell. In fact in the business enterprise, heavy use the application of the module already through very mature, no one would like to rewrite those logics for their applied procedure.HTML and sketch the designer handed over to the implement work of their design the Web plait the one who write, make they have to double work- Usually is the handicraft plait to write, because have no fit tool and can carry the script and the HTML contents knot to the server to put together. Chien but speech, apply the complexity of the procedure along with the Web to promote continuously, the development method that take page as the center limits sex to become to get up obviously.At the same time, the people always look for the better method of build up the Web application procedure, the module spreads in customer's machine/ server the realm. JavaBeans and ActiveX were published the company to expand to apply the procedure developer for Java and Windows to use to come to develop the complicated procedure quickly by" the fast application procedure development"( RAD) tool. These techniques make the expert in the some realm be able to write the module for the perpendicular application plait in the skill area, but the developer can go fetch the usage directly but need not control the expertise of this realm.Be a kind of take module as the central development terrace, the JSP appeared. It with the JavaBeans and Enterprise JavaBeans( EJB) module includes the model of the business and the data logic for foundation, provide a great deal of label and a script terraces to use to come to show in the HTML page from the contents of JavaBeans creation or send a present in return. Because of the property that regards the module as the center of the JSP, it can drive Java and not the developer of Java uses equally. Not the developer of Java can pass the JSP label( Tags) to use the JavaBeans that the deluxe developer of Java establish. The developer of Java not only can establish and use the JavaBeans, but also can use the language of Java to come to control more accurately in the JSP page according to the expression logic of the first floorJavaBeans.See now how JSP is handle claim of HTTP. In basic claim model, a claim directly was send to JSP page in. The code of JSP controls to carry on hour of the logic processing and module of JavaBeanses' hand over with each other, and the manifestation result in dynamic state bornly, mixing with the HTML page of the static state HTML code. The Beans can be JavaBeans or module of EJBs. Moreover, the more complicated claim model can see make from is request other JSP pages of the page call sign or Java Servlets.The engine of JSP wants to chase the code of Java that the label of JSP, code of Java in the JSP page even all converts into the big piece together with the static state HTML contents actually. These codes piece was organized the Java Servlet that customer can not see to go to by the engine of JSP, then the Servlet edits and translate them automatically byte code of Java.Thus, the visitant that is the website requests a JSP page, under the condition of it is not knowing, an already born, the Servlet actual full general that prepared to edit and translate completes all works, very concealment but again and efficiently. The Servlet is to edit and translate of, so the code of JSP in the web page does not need when the every time requests that page is explain. The engine of JSP need to be edit and translate after Servlet the code end is modify only once, then this Servlet that editted and translate can be carry out. The in view of the fact JSP engine auto is born to edit and translate the Servlet also, need not procedure member begins to edit and translate the code, so the JSP can bring vivid sex that function and fast developments need that you are efficiently.Compared with the traditional CGI, the JSP has the equal advantage. First, on the speed, the traditional procedure of CGI needs to use the standard importation of the system to output the equipments to carry out the dynamic state web page born, but the JSP is direct is mutually the connection with server. And say for the CGI, each interview needs to add to add a progress to handle, the progress build up and destroy by burning constantly and will be a not small burden for calculator of be the server of Web. The next in order, the JSP is specialized to develop but design for the Web of, its purpose is for building up according to the Web applied procedure, included the normand the tool of a the whole set. Use the technique of JSP can combine a lot of JSP pages to become a Web application procedure very expediently.外文资料译文JSP的技术发展历史Java Server Pages(JSP)是一种基于web的脚本编程技术,类似于网景公司的服务器端Java脚本语言——server-side JavaScript(SSJS)和微软的Active Server Pages(ASP)。

JSP技术---外文文献

JSP技术---外文文献

外文文献JSP Technology and ServletsJSP profileJSP(JavaServer Pages)is initiated by Sun Microsystems,Inc.,with many c ompanies to participate in the establishment of a dynamic web page technical standards.JSP technology somewhat similar to ASP technology,it is in the tra ditional HTML web page document(*.htm,*.html)to insert the Java program ming 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 also available for other operating systems.JSP technology to use the Java programming language prepared by the c ategory of XML tags and scriptlets,to produce dynamic pages package proces sing 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 and display separation ,support reusable component-based design,Web-based application develop ment is rapid and easy.Web server in the face of visits JSP page request,the first 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 the Ja va programming operation of the database can be reoriented websites,in ord er to achieve the establishment of dynamic pages needed to function.JSP and Java Servlet,is in the implementation of the server,usually returned to the clie nt is an HTML text,as long as the client browser will be able to visit.JSP1.0specification of the final version is launched in September1999,D ecember has introduced1.1specifications.At present relatively new is JSP1.2 norms,JSP2.0norms of the draft has also been introduced.JSP pages from HT ML code and Java code embedded in one of the components.JS script language synopsisJS is javascrip,Javascript is one kind the script language which comes by t he Netscape LiveScript development,the main purpose is to solve the server t erminal language,for instance Perl,carry-over speed question.At that time se rved the end to need to carry on the confirmation to the data,because the network speed was quite slow,only then28.8kbps,the confirmation step waste's t ime were too many.Therefore Netscape browser Navigator has joined Javascri pt,has provided the data confirmation basic function.The JavaScript official name is“ECMAScript”.This standard by ECMA orga nization development and maintenance.ECMA262is the official JavaScript sta ndard.This standard based on JavaScript(Netscape)and JScript(Microsoft).N etscape(Navigator2.0)Brendan Eich has invented this language,started from 1996,already appeared in all Netscape and in the Microsoft browser.The ECM A262development began in1996,in1997July,the ECMA general meeting ha s accepted its first edition.The script uses one specific descriptive language,rests on certain form co mpilation to be possible the execution document,is also called as great or the batch run document.The script usually may transfer temporarily by the applic ation procedure and carry out.Each kind of script present widely is applied in t he homepage design,because the script not only may reduce the homepage t he scale and raises the homepage browsing speed,moreover may enrich the homepage performance,like animation,sound and so on.Cites a most comm on example,when we click in the homepage the Email address can transfer O utlook Express or the Foxmail this kind of mail software automatically,is realize s through the script function.Also because of script these characteristics,the h uman who harbors ulterior motives by some are often using.For example join s some destruction computer system's order in the script,like this works as the user browsing homepage,once transfers this kind of script,will then cause th e user the system to come under the attack.Therefore the user should act acc ording to visits homepage the trust degree selective security rank,specially re garding these itself content on the illegal homepage,do not permit the use sc ript easily.Through“the safe establishment”the dialog box,the choice“the sc ript”under option each kind of establishment may with ease realize to script b eing forbid and begins using.JSP and ServletsThe technology of JSP and Servlet is the most important technology whic h use Javatechnology to exploit request of server,and it is also the standard which e xploit business application.Java developers prefer to use it for a variety of reas ons,one of which is already familiar with the Java language for the developme nt of this technology are easy to learn Java to the other is"a preparation,run e verywhere"to bring the concept of Web applications,To achieve a"one-prep ared everywhere realized."And more importantly,if followed some of the prin ciples of good design,it can be said of separating and content to create high-quality,reusable,easy to maintain and modify the application.For example,if t he document in HTML embedded Java code too much(script),will lead the de veloped application is extremely complex,difficult to read,it is not easy reuse, but also for future maintenance and modification will also cause 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 HTML and Java code m ixed together.This is the random development of the defects.Early dynamic pages mainly CGI(Common Gateway Interface,public Gate way Interface)technology,you can use different languages of the CGI progra ms,such as VB,C/C++or Delphi,and so on.Though the technology of CGI is developed and powerful,because of difficulties in programming,and low eff iciency,modify complex shortcomings,it is gradually being replaced by the tre nd.Of all the new technology,JSP/Servlet with more efficient and easy to pro gram,more powerful,more secure and has a good portability,they have been many people believe that the future is the most dynamic site of the future dev elopment of technology.Similar to CGI,Servlet support request/response model.When a custom er submit a request to the server,the server presented the request Servlet,Ser vlet responsible for handling requests and generate a response,and then gave the server,and then from the server sent to the customer.And the CGI is diffe rent,Servlet not generate a new process,but with HTTP Server at the same pr ocess.It threads through the use of technology,reduce the server costs.Servle t handling of the request process is this:When received from the client's reque st,calling service methods,the method of Servlet arrival of the first judgement is what type of request(GET/POST/HEAD…),then calls the appropriate trea tment(DoGet/doPost/doHead…)and generate a response.Although such a complex,in fact,simply said to Servlet is a Java class.An d the general category of the difference is that this type operating in a Servlet container,which can provide session management and targeted lifecycle man agement.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 d atabase 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.It allows conventional static and dynamic HTML content generate d by combining an HTML page looks like,but as a Servlet to run.There are ma ny commercial application server support JSP technology,such as BEA WebLo gic,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 F angdao any static HTML files can be placed,do not have to compile,do not ha ve 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 co ntains 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 docume nt will first be translated into a JSP engine Java source files,is actually a Servlet, and compiler,and then,like other Servlet,from Servlet engine to handle.Servl et engine of this type loading,handling requests from customers,and the resu lts returned to the customer.After another visit this page to the customer,as long as the paper there h ave been no changes,JSP engine has been loaded directly call the Servlet.If y ou have already been modified,it will be once again the implementation of th e above process,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 the above process,so will spend some time after such a visit would n ot.Java servlets offer a powerful API that provides access to all the informati on about the request,the session,and the bining JSP with ser vlets lets you clearly separate the application logic from the presentation of the application;in other words,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 that extends a server with functionality for process ing a request and producing a response.It's implemented using the classes an d interfaces defined by the Servlet API.The API consists of two packages:the j avax.servlet package contains classes and interfaces that are protocolindepen dent,while the javax.servlet.http package provides HTTP-specific extensions a nd utility classes.What makes a servlet a servlet is that the class implements an interface na med javax.servlet.Servlet,either directly or by extending one of the support cla sses.This interface defines the methods used by the web container to manage and interact with theservlet.A servlet for processing HTTP requests typically extends thejavax.servlet.http.HttpServlet class.This class implements the Servlet interfac e and provides additional methods suitable for HTTP processing.Servlet LifecycleThe web container manages 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 the instance.For an HttpServlet,the conta iner calls the following methods at the appropriate times in the servlet lifecycle .Besides the doGet()and doPost()methods,there are methods correspondi ng to the other HTTP methods:doDelete(),doHead(),doOptions(),doPut(), and doTrace().Typically you don't implement these methods;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 methods are rarely used in a web application.It's important to realize that the container creates only one instance of ea ch servlet.This means that the servlet must be thread safe-able to handle mu ltiple requests at the same time,each executing as a separate thread through the servlet code.Without getting lost in details,you satisfy this requirement wit h regards to instance variables if you modify the referenced objects only in the init()and destroy()methods,and just read them in the request processing m ethods.Compiling and Installing a ServletTo compile a servlet,you must first ensure that you have the JAR file cont aining all Servlet API classes in the CLASSPATH environment variable.The JAR file is distributed with all web containers.Tomcat includes it in a file called servl et.jar,located in the common/lib directory.On a Windows platform,you inclu de the JAR file in the CLASSPATH.Reading a RequestOne of the arguments passed to the doGet()and doPost()methods is an object that implements the HttpServletRequest interface.This interface define s methods that provide access to a wealth of information about the request.Generating a ResponseBesides the request object,the container passes an object that implements t he HttpServletResponse interface as an argument to the doGet()and doPost( )methods.This interface defines methods for getting a writer or stream for th e response body.It also defines methods for setting the response status code and headers.Using Filters and ListenersThe servlet specification defines two component types beside servlets:filters and listeners.These two types were introduced in the Servlet2.3specification, so if you're using a container that doesn't yet support this version of the specif ication,I'm afraid you're out of luck.FiltersA filter is 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 makes it easy to centralize tasks that apply to all requests,such as access c ontrol,logging,and charging for the content or the services offered by the ap plication.A filter has full access to the body and headers of the request and re sponse,so it can also perform various transformations.One example is compr essing the response body if the Acceptlanguage request header indicates tha t the client can handle a compressed response.A filter can be applied to either a specific servlet or to all requests matchi ng a URL pattern,such as URLs starting with the same path elements or havin g the same extension.ListenersListeners allow your application to react 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 could do this by letting th e object saved as a sessionattributimplement the HttpSessionBindingListener interface.With the new interfaces introduced in the2.3version of the specific ation,you can create listeners for servlet context and session lifecycle events a s well as session activation and passivation events(used by a container that te 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 attribu te binding events for all sessions in one place,instead of placing individual list ener objects in each session.The new types of listeners follow the standard Java event model.In other words,a listener is a class that implements one or more of the listener interfac es.The interfaces define methods that correspond to events.The listener 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 a ListenerBeans like this typically need to be initialized before they can be used.Forinstance,they may need a reference to a database or some other external data source and may create an initial information cache in memory to providefast access even to the first request for data.You can include code for initializ ation 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 the oth er parts of the application work on the assumption that the resources are alrea dy initialized and available.An application lifecycle listener is a perfect tool for this type of resource initialization.This type of listener implements the javax.s ervlet.ServletContextListener interface,with methods called by the container w hen the application starts and when it shuts down.Picking the Right Component Type for Each TaskThe Project Billboard application introduced is a fairly complex applicatio n.Half the pages are pure controller and business logic processing,it accesses a database to authenticate users,and most pages require access control.In re al life,it would likely contain even more pages,for instance,pages for access t o a shared document archive,time schedules,and a set of pages for administr ation.As the application evolves,it may become hard to maintain as a pure JS P application.It's easy to forget to include the access control code in new pag es.This is clearly an application that can benefit from using a combination of JSP pages and the component types defined by the servlet specification for th e MVC roles.Let's look at the main requirements and see how we can map the m to appropriate component types:Database access should be abstracted,to avoid knowledge of a specific d ataschema or database engine in more than one part of the application:beans i n the role of Model can be used to accomplish this.The database access beans must be made available to all other parts of th eapplication when it starts:an application lifecycle event listener is the perfect component type for this task.Only authenticated users must be allowed to use the application:a filter can perform access control to satisfy this requirement.Request processing is best done with Java code: a servlet, acting as the Controller fits the bill.It must be easy to change the presentation: this is where JSP shines, acting as the View.Adding servlets,listeners,and filters to the mix minimizes the need for complex logic in the JSP pages.Placing all this code in Java classes instead ma kes it possible to use a regular Java compiler and debugger to fix potential pro blems.Centralized Request Processing Using a ServletWith a servlet as the common entry point for all application requests,y ou gain control over the page flow of the application.The servlet can decide w hich type of response to generate depending on the outcome of the requeste d action,such as returning a common error page for all requests that fail,or di fferent responses depending on the type of client making the request.With th e help from some utility classes,it can also provide services such as input valid ation,I18N preparations,and in general,encourage a more streamlined appro ach to request handling.Mapping Application Requests to the ServletThe first requirement for using a Controller servlet is that all requests m ust pass through it.This can be satisfied in many ways.If you have played arou nd a bit with servlets previously,you're probably used to invoking a servlet wit h a URI that starts with/myApp/servlet.This is a convention introduced by Sun s Java Web Server(JWS),the first product to support servlets before the API w as standardized.Most servlet containers support this convention today,even t hough it's not formally defined in the servlet specification.。

Jsp最佳实践外文文献翻译、中英文翻译、外文翻译

Jsp最佳实践外文文献翻译、中英文翻译、外文翻译

JSP best practicesJavaServer Pages (JSPs) technology is an extension of Java servlet technology and combines HTML and Java code into a single file. While Java servlet technology focuses on Java classes capable of generating HTML output with PrintWriter.println() statements, JSP technology abstracts this concept to a higher level. With JavaServer Pages, a Web developer can write static HTML pages and simply add Java code in those sections of the page that need to be dynamically generated. While this flexibility enables rapid development of simple Web applications, it can be abused, resulting in unnecessarily complex applications that are difficult to maintain, reuse, and enhance.To avoid needlessly complex applications, follow the practices I present in this article:1. Separate HTML from Java2. Place business logic in JavaBeans3. Factor general behavior out of custom tag handler classes4. Favor HTML in Java handler classes over Java in JSPs5. Use an appropriate inclusion mechanism6. Use a JSP template mechanism7. Use stylesheets8. Use the MVC pattern9. Use available custom tag libraries10. Use JSP comments in most cases11. Follow HTML best practices12. Utilize the JSP exception mechanismThese tips will help you write JSPs that are reusable and easy to maintain.(1)Separate HTML from JavaIt can be tempting to throw all Java and HTML code necessary for a Webpage into a single JSP file. In simple system development, such an approach makes it easy for someone new to the system to locate all relevant code in one place and understand how itall interacts. However, this approach becomes burdensome and costly when the application grows more complex and more developers become involved.Combining HTML and Java in the same source code can make the code significantly less readable. To enhance software readability, developers often use indentation; but mixing HTML and Java scriptlets in the same file can make useful indentation extremely difficult to maintain.Many Web development methodologies and architectures now emphasize the separation of HTML from Java code so different developers can focus on their strengths. Properly separating Java and HTML, including HTML-like JSP tags and custom tags, allows Web designers and HTML coders to work on the HTML (presentation) aspects, while Java developers work on the application′s Java (processing logic) portions. Java developers focus on business logic as they implement the behavior behind the custom tags; Web designers then use these custom tags just as they use ordinary HTML tags.(2)Place business logic in JavaBeansJava code included directly inside a JSP is not as readily accessible to other JSPs as Java code contained within a JavaBean. Common behavior and business logic placed in JavaBeans can not only be used by other JSPs but also by other portions of the application. That is because JavaBeans are merely Java classes that satisfy some basic conventions (such as a constructor with no arguments and public get/set methods for private data members) and can be used as any other Java class. Note that Enterprise JavaBeans (EJBs) are also useful for storing behaviors and data common to all components of the application.(3)Factor general behavior out of custom tag handler classesJava classes known as custom tag handlers implement custom tags. Unlike JavaBeans, custom tag handler classes are not readily used like ordinary Java utility classes. Instead, custom tag handler classes implement specific interfaces -- or extend classes that provide these interfaces′basic implementations. Because they are not readily reused outside JSPs, custom tag handlers should contain only specific behavior that would not be useful outside that custom tag -- that is, outside the JSP. Custom tags often require support for common behaviors or business logic and can utilize JavaBeans or EJBs that perform those common behaviors.(4)Favor HTML in Java handler classes over Java in JSPsSometimes cleanly separating HTML, JSP tags, and HTML-like custom tags from Java requires unnecessarily convoluted code. In these cases, you either include Java scriptlets and expressions in the JSP or put some HTML code in the Java tag handler class.I′d rather see a small amount of HTML code in the Java class than see Java, such as scriptlets and expressions, in the JSP. Since custom tag handlers are specific to the custom tags they implement (and not reusable outside JSPs), placing necessary HTML there is not troublesome. Sun′s Java 2 Platform, Enterprise Edition (J2EE) Blueprints documentation discusses this issue further.(5)Use an appropriate inclusion mechanismIt is rarely good design to reproduce code commonly used by different application pieces each time another piece of that application needs that functionality. Factoring common JSP or HTML code out of multiple pages and into a single file improves maintainability (you need to make changes in only one location) and reusability.Two JSP include mechanisms reduce code redundancy and promote reusability; to ensure that you use the appropriate include mechanism, it is important to know the differences between the two. Generally, I use the include directive unless I can justify a need for the include action. Question 7 in the Blueprints′"Web Tier" section provides a good resource for understanding the differences between the two include mechanisms and determining which to use in a particular situation.(6)Use a JSP template mechanismA template mechanism allows for a common file to control Webpage, or JSP, layout. Then, when you want to change the layout, you need to modify only one file, and all the other pages will reflect the layout change. This doesn′t just make for more maintainable code; using templates to control layout also makes Webpages more aesthetically pleasing to users who see consistent layouts for all an application′s pages.(7)Use stylesheetsJust as templates enable developers to place layout control in a single location, stylesheets enable developers to place appearance control in a single location. I use Cascading Style Sheets (CSS) to control such items as font families, font sizes, and table characteristics. Like templates, stylesheets allow the developer to make changes in onelocation; those changes immediately reflect on all appropriate pages, resulting in increased maintainability and consistent appearance to users.(8)Use the MVC patternWhile other design patterns can be used effectively with JSPs, I often use the Model-View-Controller (MVC) architecture with JSP technology. MVC enables the development of applications that are easier to create, test, maintain, and enhance. In JSP terminology, implementation of an MVC architecture is often referred to as Model 2 (from an early JSP specification). The J2EE Blueprints samples are based on MVC.(9)Use available custom tag librariesWhy should developers spend time reinventing the wheel and worrying about testing and debugging when custom tag libraries are readily available for many different purposes? Some vendors provide custom tag libraries to their customers for free or for individual purchase, but many custom tags can be found online. Resources provides a good starting point for locating potentially useful tag libraries.While these third-party custom tag libraries occasionally have bugs, most likely such problems will be discovered, since many developers use these libraries and test them in their own applications. Also, many custom tags are open source, so you can edit them to meet your needs.I find it well worth my time to keep informed of available custom tags, since these libraries often provide functionality common to most Web applications. While learning about available custom tag libraries requires a small time investment, reusing already-available custom tags saves the time of writing, testing, and debugging my own custom tags. As mentioned above, many tag libraries are also open source; in these cases,I can readily adapt general behavior to my specific project′s situation.(10)Use JSP comments in most casesAppropriate commenting seems to challenge software developers. JSPs, like other types of code, should include comments that describe complex or extraordinary functionality, the pages′purpose, and other general information typically commented out in source code.Since JSPs allow developers to intermix Java, JSP tags, and HTML tags in the same page, there are multiple ways to comment a JSP page. Developers should carefully consider which type of comment to employ in the page. HTML comments will beviewable in the compiled JSP′s HTML source code, and both major browsers make viewing this source easy. JSP comments, on the other hand, are not placed in the HTML document created by the JSP compilation process. These comments cannot be viewed as part of the page′s source through the browser, and they do not increase the size of the rendered page′s generated source. Java comments can also occur in a JSP inside Java scriptlet sections. These are not viewable in the browser either, but including Java comments in the JSP page violates the principle of separating Java from the HTML.Code comments are usually meant for developers who write and maintain code. Therefore, use JSP comments unless there is a compelling reason to have the comments display in the browser upon request.(11)Follow HTML best practicesWhen Java is factored out of the JSP and into JavaBeans and custom tag handlers, the JSP consists mostly of JSP tags, including custom tags, and HTML tags. To make the JSP easier to understand and maintain, follow best practices related to HTML development.(12)Utilize the JSP exception mechanismWhile a thrown exception′s stack trace proves extremely useful for developers when debugging their code, it is rarely desirable to share an entire exception stack trace with the software′s users. Lengthy stack traces are not aesthetically pleasing and can increase security risks by exposing information that does not need to be released. JSPs allow developers to catch and handle exceptions in the code, resulting in more secure and aesthetically pleasing exception handling. See Resources for details on the mechanics of JSP exception handling.Exception information is more useful if information besides the stack trace is included. JSPs can use session variables to store information about the current page and current operation being performed. Then, if an exception does occur, the exception page will be called; it will have access to both the thrown exception and the information about the original page that caused the exception. The exception page can utilize underlying Java code, in JavaBeans or EJBs, to store in the database the complete exception information, related session information, and the exception′s date and time.To reduce the unsightly error messages printed to the screen and improve security, the exception page need only print out a simple error message and perhaps an identifyingnumber that allows developers to locate more detailed exception information in the database. For aesthetic and security reasons, I prefer storing most of the exception information in a database or flat file rather than printing it all to the screen. Storing the exception information in a database or flat file also allows the information to be persisted even when a user exits the application. Note that during development you should print full exception information to the screen for regular testing and debugging.Jsp最佳实践Jsp技术是servlet技术的扩展,结合html、java代码于一个文件。

计算机 JSP web 外文翻译 外文文献 英文文献

计算机 JSP web 外文翻译 外文文献 英文文献

外文资料所译外文资料:①作者:Dan Malks②书名:Professional JSP③出版时间: 2000.7.26④所译章节: Chapter 1212.1IntroductoryGood Web application design tries to separate business objects, presentation, and manipulation of the objects into distinct layers. One benefit of using JavaServer Pages technology is that it allows us to separate the role of a Web designer more clearly from that of a software developer. While on a small-scale project, one individual may occupy both roles, on a larger project, they are likely to be separate and it is beneficial to separate their workflows as much as possible. Designing the architecture for your Web application is crucial to this separation.12.2 JSP architectureWe will examine a variety of ways to architect a system with JavaServer Pages, servlets, and JavaBeans. We will see a series of different architectures, each a development of the one before. The diagram below shows this process in outline; the individual parts of the diagram will be explained in turn later in this article.JSP architecture:When Sun introduced Java Server Pages, some were quick to claim that servlets had been replaced as the preferred request handling mechanism in Web-enabled enterprise architectures. Although JSP is a key component of the Java 2 Platform Enterprise Edition (J2EE) specification, serving as the preferred request handler and response mechanism, we must investigate further to understand its relationship with servlets.Other sections of Professional JSP explain the implementation details of JSP source translation and compilation into a servlets. Understanding that JSP is built on top of the servlet API, and uses servlet semantics, raises some interesting questions. Should we no longer develop stand-alone servlets in our Web-enabled systems? Is there some way to combine servlets and JSPs? If so, where do we place our Java code? Are there any other components involved in the request processing, such as JavaBeans? If so, where do they fit into the architecture and what type of role do they fulfill?It is important to understand that, although JSP technology will be a powerful successor to basic servlets, they have an evolutionary relationship and can be used in a cooperative and complementary manner.Given this premise, we will investigate how these two technologies, each a Java Standard Extension, can be used co-operatively along with other components, such as JavaBeans, to create Java-based Web-enabled systems. We will examine architecturalissues as they relate to JSP and servlets and discuss some effective designs while looking at the tradeoffs of each. Before jumping directly into a discussion of specific architectures, though, we will briefly examine the need to develop a variety of architectures.12.3 Code factoring and role separationOne of the main reasons why the JavaServer Pages technology has evolved into what it is today (and it's still evolving) is the overwhelming technical need to simplify application design by separating dynamic content from static template display data. The foundation for JSP was laid down with the initial development of the Java Web Server from Sun, which used page compilation and focused on embedding HTML inside Java code. As applications came to be based more on business objects and n-tier architectures, the focus changed to separating HTML from Java code, while still maintaining the integrity and flexibility the technology provided.In Chapter 5, JSP Sessions, in Professional JSP, we saw how beans and objects can be bound to different contexts just by defining a certain scope. Good application design builds on this idea and tries to separate the objects, the presentation, and the manipulation of the objects into distinct, distinguishable layers.Another benefit of using JSP is that it allows us to more cleanly separate the roles of a Web production/HTML designer individual from a software developer. Remember that a common development scenario with servlets was to embed the HTML presentation markup within the Java code of the servlet itself, which can be troublesome. In our discussion, we will consider the servlet solely as a container for Java code, while our entire HTML presentation template is encapsulated within a JSP source page. The question then arises as to how much Java code should remain embedded within our JSP source pages, and if it is taken out of the JSP source page, where should it reside?Let's investigate this further. On any Web-based project, multiple roles and responsibilities will exist. For example, an individual who designs HTML pages fulfills a Web production role while someone who writes software in the Java programming language fulfills a software development role.On small-scale projects these roles might be filled by the same individual, or two individuals working closely together. On a larger project, they will likely be filled by multiple individuals, who might not have overlapping skill sets, and are less productive if made too dependent on the workflow of the other.If code that could be factored out to a mediating servlet is included instead within HTML markup, then the potential exists for individuals in the software development role and those in the Web production role to become more dependent than necessary on the progress and workflow of the other. Such dependencies may create a more error-prone environment, where inadvertent changes to code by other team members become more common.This gives us some insight into one reason why we continue to develop basic servlets: they are an appropriate container for our common Java code that has been factored out of our JSP pages, giving our software development team an area of focus that is as loosely coupled to our JSP pages as possible. Certainly, there will be a need for these same individuals to work with the JSP source pages, but the dependency is reduced, and these pages become the focus of the Web-production team instead. Of course, if the same individual fulfills both roles, as is typical on a smaller project, such dependencies are not a major concern.So, we should try to minimize the Java code that we include within our JSP page, in order to uphold this cleaner separation of developer roles. As we have discussed, some of this Java code is appropriately factored to a mediating servlet. Code that is common to multiple requests, such as authentication, is a good candidate for a mediating servlet. Such code is included in one place, the servlet, instead of potentially being cut and pasted into multiple JSPs.We will also want to remove much of our business logic and data access code from our JSP page and encapsulate it within JavaBeans, called worker or helper beans. We start to see a pattern of code movement from our JSP into two areas: a servlet (or JSP) that sits in front of the main JSP, and JavaBeans that sit in back. We refer to this common pattern as "Factor Forward -- Factor Back," as shown in the figure below:Factor Forward -- Factor Back:Another way to think about what code should be localized and encapsulated is that our JSP page should reveal as little as possible of our Java code implementation details.Rather, the page should communicate our intent by revealing the delegating messages we send to worker beans, instructing them to get state from a model, or to complete some business processing.12.4 Redirecting and forwardingRedirecting and forwarding requests in JSPs and servlets takes place often, and it is important to understand the subtle difference between these two mechanisms even though they achieve the same goal (that is, a client asks for a resource on the server and a different resource is served to it):●When a servlet or JSP resource chooses to redirect the client (using aresponse.sendRedirect(url)) the request object does not reach the second resource directly since the underlying implementation is an HTTP redirect.The server sends an HTTP 302 message back to the client telling it that the resource has moved to another URL, and that the client should access it there.The bottom line is that the lifecycle of the initial request object that was accessed in the first JSP terminates with the end of the service method in the first JSP, or with the reply from the server.●In a forward mechanism the request object is forwarded to the second resource,thus maintaining any object bindings to the request and its state, without a round trip to the client on the network. This allows the first JSP to do some work internally and then send information to the second JSP asking it to do itsbit. (Servlets used a chaining mechanism to do this). See Chapter 5, JSP Sessions, in Professional JSP to get a clearer picture of scope. JSPs and servlets can use the forwarding mechanism to delegate tasks among themselves, in the process of separating dynamic and static content.Now, let's investigate how we build these systems.12.5 ArchitecturesBefore discussing specific architectures that we can use to build systems with servlets and JSP, it is worth mentioning two basic ways of using the JSP technology. Each of the architectures discussed in this chapter will be based on one of these approaches:●The first method is referred to here as the page-centric (or client-server)approach. This approach involves request invocations being made directly to JSP page.●In the second method, the dispatcher (or n-tier) approach, a basic servlet orJSP acts as a mediator or controller, delegating requests to JSP pages and JavaBeans.We will examine these approaches in light of a simple example, which will evolve to satisfy the requirements of various scenarios. The initial scenario involves providing a Web interface for guessing statistics about a soon-to-be-born baby. The guesses are stored, and can be reviewed later by the parents, to see who has guessed the closest. As the requirement scenarios become more sophisticated, such as adding the desire for a persistence mechanism, the solution scenarios will become more sophisticated, as well. Thus, our example will evolve and we will gain an understanding of how the various architectures that we discuss will help us build a system that satisfies these requirements in an elegant and effective manner.12.6 The page-centric approachApplications built using a client-server approach have been around for some time; they consist of one or more application programs running on client machines and connecting to a server-based application to work. (A good example would be a PowerBuilder or Oracle Forms-based system.) CGIs and pre-servlet applications were generally based on this simple 2-tier model, and with the introduction of servlets, 2-tier applications could also be created in Java.This model allows JSPs or servlets direct access to some resource like a database or legacy application to service a client's request: the early JSP specifications termed this a "Model 1" programming approach. The JSP page is where the incoming request is intercepted and processed, and the response is sent back to the client;JSPs only differed from servlets in this scenario by providing cleaner code and separating code from the content by placing data access in beans.Model 1 programming approach:The advantage of such an approach is that it is siple to program,and allows the page author to Generate dynamic content easily,based upon the request and the state resources.However this architecture does not scale up well for a large number of simultaneous clients since there would be a significant amount of request processing to be performed,and each request must establish or share a potentially scarce/expensive connection to the resource in question.(A good example would be JDBC connectons in servlets or JSPs and the need for connection pools.) Indiscriminate usage of this architecture usually leads to a significant amount of Java code embedded within the JSP page,this may not seem to be much of a problem for Java developers but it is certainly an issue if the JSP pages are maintained by designers:the code tends to get in the designe’s way,and you run the risk of your code becoming corrupted when others are tweaking the look and feel.译文12.1前言好的Web应用设计试图将业务对象,简报以及操作对象分为不同的层面。

5计算机专业 外文文献 英文文献 外文翻译 jsp应用框架 中英对照大学毕设论文

5计算机专业 外文文献 英文文献 外文翻译 jsp应用框架 中英对照大学毕设论文

外文原文JSP application frameworksbrian wright、michael freedman/pdf/introduction-to-machine-learning/ What are application frameworks:A framework is a reusable, semi-complete application that can be specialized to produce 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 to the same hard disks. Developers working on conventional desktop applications are accustomed to toolkits and development environments that leverage the sameness between applications. Application frameworks build on this common ground to provide developers with a reusable structure that can serve as the foundation for their own products.A framework provides developers with a set of backbone components that have the following characteristics:1.They are known to work well in other applications.2. They are ready to use with the next project.3. They can also be used by other teams in the organization.Frameworks are the classic build-versus-buy proposition. If you build it, you will understand 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 observers would agree that frameworks such as Struts provide a significant return on investment compared to starting from scratch, especially for larger projects.Other types of frameworks: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 Lucene 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 toprovide a custom component.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 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.Enabling technologies: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 developers 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 technologies can help you devise creative solutions to tricky problems.Hypertext Transfer Protocol (HTTP):When mediating talks between nations, diplomats often follow a formal protocol.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 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 running on the server.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 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.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 negotiating 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.Another reason HTTP has become the universal standard is its simplicity. An HTTP request looks like an ordinary text document. This has made it easy forapplications to make HTTP requests. You can even send an HTTP request by hand using a standard utility such as Telnet. When the HTTP response comes back, it is also in plain text that developers can read.The first line in the HTTP request contains the method, followed by the location of 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 version, 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.Once the server has received and serviced the request, 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, the server will return a set of HTTP response headers that work in a way similar to the request headers.As we mentioned, HTTP does not preserve state information between requests.The server logs the 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 always bliss.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 special 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 not traffic in dynamic content. It mainly uses the request to locate a file and then returns that file in the response. The file is typically formatted using Hypertext Markup Language (HTML) [W3C, HTML] that the web browser can format and display. The HTML page often includes hypertext links to other web pages and may display any number of other goodies, such as images and videos. The user clicks a link to make another request, and the process begins a new.Standard web servers handle static content and images quite well but need a helping hand to provide users with a customized, dynamic response.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 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.Common Gateway Interface (CGI):The first widely used standard for producing dynamic content was the Common Gateway Interface (CGI). CGI uses standard operating system features, such as environment variables 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 create a customized response.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 CGI program runs and sends its output back to the server. The web server then relays the response to the browser.CGI defines a set of conventions regarding what information it will pass as environment 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.The main drawback to 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 drawback is that CGI programs tend to be platform dependent. A CGI program written for one operating system may not run on another.Java servlets:Sun’s Java Servlet platform directly 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 servlets are portable between operating systems that have a Java Virtual Machine (JVM).A servlet looks and feels like a miniature web server. It receives a request and renders a response. But, unlike conventional web servers, the servlet application programming interface (API) is specifically designed to help Java developers createdynamic applications.The servlet itself is simply a Java class 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 all your other Java assets.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 declare 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.But unlike 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 processes 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 database connections or EJB Home Interfaces, so that they can be shared between requests. Acquiring resources like these can take several seconds—which is longer than many surfers are willing to wait.The other edge of the sword is that, since servlets are multithreaded, servlet developers must take special care to be sure their servlets are thread-safe. To learn more about servlet programming, we recommend Java Servlets by Example, by Alan R. Williamson [Williamson]. The definitive source for Servlet information is the Java Servlet Specification [Sun, JST].JavaServer Pages:While Java servlets are a big step up from CGI programs, they are not a panacea. To generate the response, developers are still stuck with using println statements to render the HTML. Code that looks like:out.println("<P>One line of HTML.</P>");out.println("<P>Another line of HTML.</P>");is all too common in servlets that generate the HTTP response. There are libraries that can help you generate HTML, but as applications grow more complex, Java developers end up being cast into the role of HTML page designers.Meanwhile, given the choice, most project managers prefer to divide development teams into specialized groups. They like HTML designers to be working on the presentation while Java engineers sweat the business logic. Using servlets alone encourages mixing markup with business logic, making it difficult for team members to specialize.To solve this problem, Sun turned to the idea of using server pages to combine scripting and templating technologies into a single component. To build Java Server Pages, developers start by creating HTML pages in the same old way, using the same old HTML syntax. To bring dynamic content into the page, the developer can also place JSP scripting elements on the page. Scripting elements are tags that encapsulate logic that is recognized by the JSP. You can easily pick out scripting elements on JSP pages by looking for code that begins with <% and ends with %>.To be seen as a JSP page, the file just needs to be saved with an extension of .jsp.When a client requests the JSP page, the container translates the page into a source code file for a Java servlet and compiles the source into a Java class file—just as you would do if you were writing a servlet from scratch. At runtime, the container can also check the last modified date of the JSP file against the class file. If the JSP file has changed since it was last compiled, the container will retranslate and rebuild the page all over again.Project managers can now assign the presentation layer to HTML developers, who then pass on their work to Java developers to complete the business-logic portion. The important thing to remember is that a JSP page is really just a servlet. Anything you can do with a servlet, you can do with a JSP.JavaBeans:JavaBeans are Java classes which conform to a set of design patterns that make them easier to use with development tools and other components.DEFINITION A JavaBean is a reusable software component written in Java. To qualify as a JavaBean, the class must be concrete and public, and have a noargument constructor. JavaBeans expose internal fields as properties by providing public methods that follow a consistent design pattern. Knowing that the property names follow this pattern, other Java classes are able to use introspection to discover and manipulate JavaBean properties.The JavaBean design patterns provide access to the bean’s internal state throughtwo flavors of methods: accessors are used to read a JavaBean’s state; mutators are used to change a JavaBean’s state.Mutators are always prefixed with lowercase token set followed by the property name. The first character in the property name must be uppercase. The return value is always void—mutators only change property values; they do not retrieve them. The mutator for a simple property takes only one parameter in its signature, which can be of any type. Mutators are often nicknamed setters after their prefix. The mutator method signature for a weight property of the type Double would be:public void setWeight(Double weight)A similar design pattern is used to create the accessor method signature. Accessor methods are always prefixed with the lowercase token get, followed by the property name. The first character in the property name must be uppercase. The return value will match the method parameter in the corresponding mutator. Accessors for simple properties cannot accept parameters in their method signature. Not surprisingly, accessors are often called getters.The accessor method signature for our weight property is:public Double getWeight()If the accessor returns a logical value, there is a variant pattern. Instead of using the lowercase token get, a logical property can use the prefix is, followed by the property name. The first character in the property name must be uppercase. The return value will always be a logical value—either boolean or Boolean. Logical accessors cannot accept parameters in their method signature.The boolean accessor method signature for an on property would bepublic boolean isOn()The canonical method signatures play an important role when working with Java- Beans. Other components are able to use the Java Reflection API to discover a JavaBean’s properties by looking for methods prefixed by set, is, or get. If a component finds such a signature on a JavaBean, it knows that the method can be used to access or change the bean’s properties.Sun introduced JavaBeans to work with GUI components, but they are now used with every aspect of Java development, including web applications. When Sun engineers developed the JSP tag extension classes, they designed them to work withJavaBeans. The dynamic data for a page can be passed as a JavaBean, and the JSP tag can then use the bean’s properties to customize the output.For more on JavaBeans, we highly recommend The Awesome Power of JavaBeans, by Lawrence H. Rodrigues [Rodrigues]. The definitive source for JavaBean information is the JavaBean Specification [Sun, JBS].Model 2:The 0.92 release of the Servlet/JSP Specification described Model 2 as an architecture that uses servlets and JSP pages together in the same application. The term Model 2 disappeared from later releases, but it remains in popular use among Java web developers.Under Model 2, servlets handle the data access and navigational flow, while JSP pages handle the presentation. Model 2 lets Java engineers and HTML developers each work on their own part of the application. A change in one part of a Model 2 application does not mandate a change to another part of the application. HTML developers can often change the look and feel of an application without changing how the back-office servlets work.The Struts framework is based on the Model 2 architecture. It provides a controller servlet to handle the navigational flow and special classes to help with the data access. A substantial custom tag library is bundled with the framework to make Struts easy to use with JSP pages.Summary:In this article, we introduced Struts as an application framework. We examined the technology behind HTTP, the Common Gateway Interface, Java servlets, JSPs, and JavaBeans. We also looked at the Model 2 application architecture to see how it is used to combine servlets and JSPs in the same application.Now that you have had a taste of what it is like to develop a web application with Struts, in chapter 2 we dig deeper into the theory and practice behind the Struts architecture.外文翻译JSP 应用框架brian wright、michael freedman/pdf/introduction-to-machine-learning/ 什么是应用框架:框架(framework)是可重用的,半成品的应用程序,可以用来产生专门的定制程序。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

外文资料所译外文资料:①作者:Dan Malks②书名:Professional JSP③出版时间: 2000.7.26④所译章节: Chapter 1212.1IntroductoryGood Web application design tries to separate business objects, presentation, and manipulation of the objects into distinct layers. One benefit of using JavaServer Pages technology is that it allows us to separate the role of a Web designer more clearly from that of a software developer. While on a small-scale project, one individual may occupy both roles, on a larger project, they are likely to be separate and it is beneficial to separate their workflows as much as possible. Designing the architecture for your Web application is crucial to this separation.12.2 JSP architectureWe will examine a variety of ways to architect a system with JavaServer Pages, servlets, and JavaBeans. We will see a series of different architectures, each a development of the one before. The diagram below shows this process in outline; the individual parts of the diagram will be explained in turn later in this article.JSP architecture:When Sun introduced Java Server Pages, some were quick to claim that servlets had been replaced as the preferred request handling mechanism in Web-enabled enterprise architectures. Although JSP is a key component of the Java 2 Platform Enterprise Edition (J2EE) specification, serving as the preferred request handler and response mechanism, we must investigate further to understand its relationship with servlets.Other sections of Professional JSP explain the implementation details of JSP source translation and compilation into a servlets. Understanding that JSP is built on top of the servlet API, and uses servlet semantics, raises some interesting questions. Should we no longer develop stand-alone servlets in our Web-enabled systems? Is there some way to combine servlets and JSPs? If so, where do we place our Java code? Are there any other components involved in the request processing, such as JavaBeans? If so, where do they fit into the architecture and what type of role do they fulfill?It is important to understand that, although JSP technology will be a powerful successor to basic servlets, they have an evolutionary relationship and can be used in a cooperative and complementary manner.Given this premise, we will investigate how these two technologies, each a Java Standard Extension, can be used co-operatively along with other components, such as JavaBeans, to create Java-based Web-enabled systems. We will examine architecturalissues as they relate to JSP and servlets and discuss some effective designs while looking at the tradeoffs of each. Before jumping directly into a discussion of specific architectures, though, we will briefly examine the need to develop a variety of architectures.12.3 Code factoring and role separationOne of the main reasons why the JavaServer Pages technology has evolved into what it is today (and it's still evolving) is the overwhelming technical need to simplify application design by separating dynamic content from static template display data. The foundation for JSP was laid down with the initial development of the Java Web Server from Sun, which used page compilation and focused on embedding HTML inside Java code. As applications came to be based more on business objects and n-tier architectures, the focus changed to separating HTML from Java code, while still maintaining the integrity and flexibility the technology provided.In Chapter 5, JSP Sessions, in Professional JSP, we saw how beans and objects can be bound to different contexts just by defining a certain scope. Good application design builds on this idea and tries to separate the objects, the presentation, and the manipulation of the objects into distinct, distinguishable layers.Another benefit of using JSP is that it allows us to more cleanly separate the roles of a Web production/HTML designer individual from a software developer. Remember that a common development scenario with servlets was to embed the HTML presentation markup within the Java code of the servlet itself, which can be troublesome. In our discussion, we will consider the servlet solely as a container for Java code, while our entire HTML presentation template is encapsulated within a JSP source page. The question then arises as to how much Java code should remain embedded within our JSP source pages, and if it is taken out of the JSP source page, where should it reside?Let's investigate this further. On any Web-based project, multiple roles and responsibilities will exist. For example, an individual who designs HTML pages fulfills a Web production role while someone who writes software in the Java programming language fulfills a software development role.On small-scale projects these roles might be filled by the same individual, or two individuals working closely together. On a larger project, they will likely be filled by multiple individuals, who might not have overlapping skill sets, and are less productive if made too dependent on the workflow of the other.If code that could be factored out to a mediating servlet is included instead within HTML markup, then the potential exists for individuals in the software development role and those in the Web production role to become more dependent than necessary on the progress and workflow of the other. Such dependencies may create a more error-prone environment, where inadvertent changes to code by other team members become more common.This gives us some insight into one reason why we continue to develop basic servlets: they are an appropriate container for our common Java code that has been factored out of our JSP pages, giving our software development team an area of focus that is as loosely coupled to our JSP pages as possible. Certainly, there will be a need for these same individuals to work with the JSP source pages, but the dependency is reduced, and these pages become the focus of the Web-production team instead. Of course, if the same individual fulfills both roles, as is typical on a smaller project, such dependencies are not a major concern.So, we should try to minimize the Java code that we include within our JSP page, in order to uphold this cleaner separation of developer roles. As we have discussed, some of this Java code is appropriately factored to a mediating servlet. Code that is common to multiple requests, such as authentication, is a good candidate for a mediating servlet. Such code is included in one place, the servlet, instead of potentially being cut and pasted into multiple JSPs.We will also want to remove much of our business logic and data access code from our JSP page and encapsulate it within JavaBeans, called worker or helper beans. We start to see a pattern of code movement from our JSP into two areas: a servlet (or JSP) that sits in front of the main JSP, and JavaBeans that sit in back. We refer to this common pattern as "Factor Forward -- Factor Back," as shown in the figure below:Factor Forward -- Factor Back:Another way to think about what code should be localized and encapsulated is that our JSP page should reveal as little as possible of our Java code implementation details.Rather, the page should communicate our intent by revealing the delegating messages we send to worker beans, instructing them to get state from a model, or to complete some business processing.12.4 Redirecting and forwardingRedirecting and forwarding requests in JSPs and servlets takes place often, and it is important to understand the subtle difference between these two mechanisms even though they achieve the same goal (that is, a client asks for a resource on the server and a different resource is served to it):●When a servlet or JSP resource chooses to redirect the client (using aresponse.sendRedirect(url)) the request object does not reach the second resource directly since the underlying implementation is an HTTP redirect.The server sends an HTTP 302 message back to the client telling it that the resource has moved to another URL, and that the client should access it there.The bottom line is that the lifecycle of the initial request object that was accessed in the first JSP terminates with the end of the service method in the first JSP, or with the reply from the server.●In a forward mechanism the request object is forwarded to the second resource,thus maintaining any object bindings to the request and its state, without a round trip to the client on the network. This allows the first JSP to do some work internally and then send information to the second JSP asking it to do itsbit. (Servlets used a chaining mechanism to do this). See Chapter 5, JSP Sessions, in Professional JSP to get a clearer picture of scope. JSPs and servlets can use the forwarding mechanism to delegate tasks among themselves, in the process of separating dynamic and static content.Now, let's investigate how we build these systems.12.5 ArchitecturesBefore discussing specific architectures that we can use to build systems with servlets and JSP, it is worth mentioning two basic ways of using the JSP technology. Each of the architectures discussed in this chapter will be based on one of these approaches:●The first method is referred to here as the page-centric (or client-server)approach. This approach involves request invocations being made directly to JSP page.●In the second method, the dispatcher (or n-tier) approach, a basic servlet orJSP acts as a mediator or controller, delegating requests to JSP pages and JavaBeans.We will examine these approaches in light of a simple example, which will evolve to satisfy the requirements of various scenarios. The initial scenario involves providing a Web interface for guessing statistics about a soon-to-be-born baby. The guesses are stored, and can be reviewed later by the parents, to see who has guessed the closest. As the requirement scenarios become more sophisticated, such as adding the desire for a persistence mechanism, the solution scenarios will become more sophisticated, as well. Thus, our example will evolve and we will gain an understanding of how the various architectures that we discuss will help us build a system that satisfies these requirements in an elegant and effective manner.12.6 The page-centric approachApplications built using a client-server approach have been around for some time; they consist of one or more application programs running on client machines and connecting to a server-based application to work. (A good example would be a PowerBuilder or Oracle Forms-based system.) CGIs and pre-servlet applications were generally based on this simple 2-tier model, and with the introduction of servlets, 2-tier applications could also be created in Java.This model allows JSPs or servlets direct access to some resource like a database or legacy application to service a client's request: the early JSP specifications termed this a "Model 1" programming approach. The JSP page is where the incoming request is intercepted and processed, and the response is sent back to the client;JSPs only differed from servlets in this scenario by providing cleaner code and separating code from the content by placing data access in beans.Model 1 programming approach:The advantage of such an approach is that it is siple to program,and allows the page author to Generate dynamic content easily,based upon the request and the state resources.However this architecture does not scale up well for a large number of simultaneous clients since there would be a significant amount of request processing to be performed,and each request must establish or share a potentially scarce/expensive connection to the resource in question.(A good example would be JDBC connectons in servlets or JSPs and the need for connection pools.) Indiscriminate usage of this architecture usually leads to a significant amount of Java code embedded within the JSP page,this may not seem to be much of a problem for Java developers but it is certainly an issue if the JSP pages are maintained by designers:the code tends to get in the designe’s way,and you run the risk of your code becoming corrupted when others are tweaking the look and feel.译文12.1前言好的Web应用设计试图将业务对象,简报以及操作对象分为不同的层面。

相关文档
最新文档