JSP技术概述与应用框架外文翻译
JSP应用框架外文文献
附录Ⅰ英文资料翻译英文原文JSP Application FrameworksWhat 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 components as 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 to provide 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 for applications 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 t he 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 automaticallywhen 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 , 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 create dynamic 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:("<P>One line of HTML.</P>");("<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 through two 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 onlychange 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 Jav aBean’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 with JavaBeans. The dynamic data for a page can be passed as a JavaBean, and t he 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 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.中文翻译JSP 应用框架什么是应用框架:框架(framework)是可重用的,半成品的应用程序,能够用来产生专门的定制程序。
JSP应用框架外文翻译
中文4816字外文资料翻译(2011 届大学本科)题目:学院:专业:班级:姓名:学号:主指导教师:2011年02 月24 日教务处印制外文原文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 coo kies, 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 prop erties.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)是可重用的,半成品的应用程序,可以用来产生专门的定制程序。
外文文献JSP中英文翻译
THE TECHNIQUE DEVELOPMENT HISTORY OF JSPBy:Kathy Sierra and Bert BatesSource:Servlet&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.The After Sun release the JSP(the Java Server Pages) formally,the this kind of new Web application development technique very quickly caused the peopl e’s concern.JSP provided a special development environment for the Web application that establishes the high dynamic state。
JSP技术外文翻译
JSP Technology(外文原文)JSP (JavaServer Pages) is a kind of based on Java script technology. In many of the advantages of JSP, one of which is it can the HTML code from Web pages in the business logic of the effectively separated. With JSP visit reusable components, such as Servlet, JavaBean and based on Java Web applications. JSP also support in Web page direct embedded Java code. The two methods can visit JSP files: browser to send files request, sent to the JSP Servlet request.JavaServer Pages technology is an extension of the Java Servlet technology. Servlets are platform-independent, server-side modules that fit seamlessly into a Web server framework and can be used to extend the capabilities of a Web server with minimal overhead, maintenance, and support. Unlike other scripting languages, servlets involve no platform-specific consideration or modifications; they are application components that are downloaded, on demand, to the part of the system that needs them. Together, JSP technology and servlets provide an attractive alternative to other types of dynamic Web scripting/programming by offering: platform independence; enhanced performance; separation of logic from display; ease of administration; extensibility into the enterprise; and, most importantly, ease of use.The Unified Expression Language (EL)The simple EL included in JSP technology offers many advantages to the page author. Using simple expressions, page authors can easily access external data objects from their pages. The JSP technology container evaluates and resolves these expressions as it encounters them. It then immediately returns a response because the JSP request-processing model has only one phase, the render phase. However, because therequest-processing model does not support a postback, all JSP expressions are read-only.Unlike JSP technology, JavaServer Faces technology supports a multiphase life cycle. When a user enters values into the JavaServer Faces UI components and submits the page, those values are converted, validated, and propagated to server-side data objects, after which component events are processed. In order to perform all these tasks in an orderly fashion, the JavaServer Faces life cycle is split into separate phases. Therefore, JavaServer Faces technology evaluates expressions at different phases of the life cycle rather than immediately, as JSP technology would do.JSP technology -- friend or foe?Presentation technology was designed to transform plain ol' raw Web content into content wrapped in an attractive presentation layer. JavaServer Pages (JSP) technology, Sun's presentation model and part of the J2EE platform, has received significant attention. There are both advantages and disadvantages to using JSP technology, and Web developers should be aware of the good and the bad -- and know that they don't have to be limited to this single technology. In fact, these days a number of presentation technologies are available. This article begins by defining the problems presentation technologies were designed to solve. It then examines the specific strengths and weaknesses of the JSP model. Finally, it introduces some viable alternatives to Sun's presentation technology.A bit of historyBefore diving into an explanation of presentation technology, it's helpful to fill in some details on the situation that led to the birth of the technology. Just 10 short years ago, the term thin client was a novelty. We still lived in a world of desktop applications, powered by wimpy 286 microprocessors with 14-inch monitors that we squinted at. Boy, have times changed! Now my desktop does nothing but powera Web browser, while servers from Sun, IBM, HP, Compaq, and the rest churn out computations, business logic, and content. And that little monitor? Replaced by flat-screen, plasma, whopping 21- and 25-inch beauties. Why? So we can see the intricate and complex HTML displays that serve as a front-end to these powerful applications. No longer does a clunky interface suffice; now we expect flashy graphics, moving images, color-coordinated presentations that would look good in any room in the house, and speedy rendering to boot.The premiseToday, a decade beyond those fledgling Windows applications, we are still dealing with this huge shift in the presentation paradigm. The woeful Visual Basic and C programmers who remain now find themselves working either on back-end systems or Windows-only applications, or they have added a Web-capable language such as the Java language to their toolbox. An application that doesn't support at least three of four ML-isms -- such as HTML, XML, and WML -- is considered shabby, if not an outright failure. And, of course, that means we all care very deeply about the ability to easily develop a Web presentation it turns out, using the new Internet, and all the languages we have at our disposal -- Java, C, Perl, Pascal, and Ada, among others -- hasn't been as easy as we might have hoped. A number of issues creep up when it comes to taking the programming languages everyone used for back-end systems and leveraging them to generate markup language suitable for a client. With the arrival of more options on the browser (DHTML and JavaScript coding, for example), the increase in graphic artist talent in the Web domain, and tools that could create complex interfaces using standard HTML, the demand for fancy user interfaces has grown faster than our ability to develop these front ends to our applications. And this has given rise to presentation technology was designed to perform a single task: convert content, namely data without display details, intopresentation -- meaning the various user interfaces you see on your phone, PalmPilot, or Web browser. What are the problems that these presentation technologies claimed to solve? Let's take a look.Segregation vs. integrationThe primary purpose of presentation technology is to allow a separation between content and presentation. In other words, business logic units (presumably in some programming language like C or Java) don't have to generate data in a presentation-specific manner. Data, or content, is returned raw, without formatting. The presentation technology then applies formatting, or presentation, to this content. The result is an amalgam of data surrounded by and intertwined with graphics, formatting, colors, and at the examples in Listing 1 and Listing 2 to see at a glance the difference between raw content and content combined with presentation 1 shows raw content, with nothing but data, that could be used in a variety of ways.class=displaycodeRussell CroweTom HanksMeg RyanMary Stuart MastersonAlec BaldwinAshley JuddKeanu ReevesListing 2, which is much more complex than the one above, shows the same data wrapped in presentation technology and ready for display in an HTML-capable browser.class=displaycode<HTML><HEAD><TITLE>Search Results: Actors</TITLE></HEAD><BODY><H2 ALIGN="center">Search Results: Actors</H2><CENTER><HR width="85%"><TABLE width="50%" CELLPADDING="3" CELLSPACING="3" border="1" BGCOLOR="#FFFFCC"><TR BGCOLOR="#FFCCCC"><TH width="50%" ALIGN="center">Last Name</TH><TH width="50%" ALIGN="center">First Name</TH></TR><TR><TD width="50%">Baldwin</TD><TD width="50%">Alec</TD></TR><TR><TD width="50%">Crowe</TD><TD width="50%">Russell</TD></TR><TR><TD width="50%">Hanks</TD><TD width="50%">Tom</TD></TR><TR><TD width="50%">Judd</TD><TD width="50%">Ashley</TD></TR><TR><TD width="50%">Masterson</TD><TD width="50%">Mary Stuart</TD></TR><TR><TD width="50%">Reeves</TD><TD width="50%">Keanu</TD></TR><TR><TD width="50%">Ryan</TD><TD width="50%">Meg</TD></TR></TABLE></CENTER>While the content in Listing 1 is clear and easy for the uninitiated layperson to both use and understand, the content in Listing 2 is very specific to the task of display in a browser. It is tricky to extract data from it or manipulate it for any other fundamental difference, the process of segregating content from presentation instead of integrating the two (at least until the user needs the information), is the basic premise of any presentation technology, including the JSP technology. Further, any presentation technology that does not accomplish this basic goal does not truly accomplish the goal it was created to achieve.Work vs. reworkBesides the separation of content and presentation, another measure of a presentation technology's usefulness is the amount of rework that it eliminates. The divergence of presentation and content enforces a divergence in the roles of those developing the content. A programmer can focus on the raw content presented in the examples above, and a graphic artist or webmaster can attend to the presentation. A slight overlap ofroles remains, however, in the process of taking the presentation -- or markup -- designed by the artist and applying it to the content the programmer's code the simplest case, the artist supplies the markup, and the developer provides code and also plugs the markup into the presentation technology. The application is "started up," and the content magically becomes a user interface. Of course, as we all know, development rarely ends there. Next come revisions and changes to the interface and new business rules that must be coded. This is where the true test of the presentation technology's flexibility comes into play. While it is usually simple to update the raw content being fed into the presentation layer, rarely can the graphic artists easily edit their original work. Changes to the presentation layer are common (we've all been victim to marketing departments changing this or that). So now a problem arises: what do the designers change to tweak their work? The original markup language page they gave to the developer? Probably not, as that page has most likely had custom tags or code inserted (JSP pages, template engines), converted to a Java servlet, or changed into something totally the designer must rework the original page and resubmit this page to the developer. Then the developer has to reconvert this page to the specific format needed for use in the presentation technology. Alternatively, the designer has to learn a scripting language or at least know that which areas of the page's source code from the developer are off limits. Of course, this is an error-prone, dangerous way to operate. Once you've determined that a presentation technology allows a clean split between content and presentation, you should try to ensure that a minimum amount of rework is necessary in order to make presentation changes.The promise of JSP technologyNow, on to the specifics of JSP coding. The promise of JSP technologyis to supply the designer and developer the only presentation technology they will ever need. JSP technology is part of the J2EE platform, which is the strongest show of support Sun can give one of its Java products. To give you an idea of how prevalent this solution is, try running a search on 'JSP' at ; you'll find more books devoted to JSP technology than about almost any other single Java API. Before I dive into the specific problems that JSP technology presents, you need a clear understanding of what it claims to do.Content vs. presentationAbove all, JSP technology is about separating content from presentation, foremost in Sun's published set of goals for JSP pages. In fact, JSP design stemmed directly from the complaints of developers who were tired of typing ("<HTML><HEAD><TITLE>" + () + "</TITLE></HEAD>"); into their servlet code. This mixing of hard-coded content with runtime variables presented a horrible burden on servlet developers. It also made making even minor changes to the presentation layer difficult for the technology addresses this situation by allowing normal HTML pages (and later, WML or other markup language pages) to be compiled at runtime into a Java servlet, essentially mimicking the () paradigm, without requiring the developer to write this code. And it allows you to insert variables into the page that are not interpreted until a JSP page the HTML snippet shown in could look like the example in Listing 3.class=displaycode<%@ page import="" %><%@ page import="" %><%PageInfo pageInfo = (PageInfo)("PAGE_DATA")%><HTML><HEAD><TITLE><%=()%></TITLE></HEAD><BODY><!-- Other HTML content --></BODY></HTML>Judging by these initial principles, then, JSP technology (at least in its stated design) would satisfy the first tenet of a presentation technology, as outlined above: that content be separated from presentation.Code vs. markupSecond on the JSP technology's list of features is something that might raise a bit of concern. JSP coding lets you insert Java code directly into a page of markup. To understand why this decision was made, recall that when the JSP specification was being developed, Sun's competition from Microsoft was at an all-time high, primarily due to the success of Microsoft Active Server Pages (ASP). The similarity of the name JavaServer Pages to Active Server Pages was not merely coincidental. And the ability to mimic many of ASP's features was also intentional. So JSP authors were given the option to add Java code into their an example of Java code being added to markup, the JSP snippet in Listing 4 dynamically adds rows as needed to show each item in the Vector of actors.class=displaycode<%@ page import="" %><%@ page import="" %><%@ page import="" %><%@ page import="" %><%@ page import="" %><%PageInfo pageInfo = (PageInfo)("PAGE_DATA")Vector actors = ()%><HTML><HEAD><TITLE><%=()%></TITLE></HEAD><BODY><H2 ALIGN="center">Search Results: Actors</H2><CENTER><HR width="85%"><TABLE width="50%" CELLPADDING="3" CELLSPACING="3" border="1" BGCOLOR="#FFFFCC"><%for (Iterator i = (); ()) {Actor actor = (Actor)();%><TR BGCOLOR="#FFCCCC"><TH width="50%" ALIGN="center"><%=()%></TH><TH width="50%" ALIGN="center"><%=()%></TH></TR><%}%></TABLE></CENTER></BODY></HTML>Remember that so far I am simply describing the initial design goals of JSP technology; I'll defer my own judgment about the goals until a later section about the problems of JSP technology. You might be a little suspicious already, however, since embedding code into a JSP page would seem to cause problems with the first goal of JSP technology, separating content from presentation. But really (ahem), I'm not editorializing yet.Designer vs. developerA final (and admirable) goal of JSP technology worth mentioning is that it seeks to establish clearly defined roles in the application development process. By ostensibly breaking content from presentation, JSP technology creates a clearer distinction between the designer and developer. The designer creates markup, using only standard HTML, WML, or whatever language is appropriate, and the developer writes code. Of course, many designers today have learned JavaScript, so it should come as no surprise that many of these same designers have begun to learn JSP coding. Often, instead of just doing pure markup, they encode a complete JSP page and hand it over to the developer. Then the usual tweaking takes place, and the developer puts the JSP page into place as a front-end for some portion of the overall application. The key, though, is that manydesigners do not learn JSP coding, so it must also be workable in that environment.The problemsI've spelled out what a good presentation technology should provide, as well as the specific problems that JSP technology seeks to address. Now, I'm ready to cut to the chase: JSP technology, while built on good ideas, presents quite a few problems. Before you choose to use JSP coding in your applications (which you might still do), you should at least be aware of possible should also be aware of a facet of the J2EE programming platform that is often ignored: just because an API comes with the platform doesn't mean you have to use it. As silly as this sounds, many developers are struggling with the JSP, or EJB, or JMS APIs, thinking if they don't use these APIs, their applications somehow won't really be "J2EE applications." In fact, the platform boasts more APIs than most applications need. If you have problems with or doubts about JSP technology, you don't have to use it! Take a close look at both the positives and the negatives before choosing to use JSP technology in your applications. Let's take a look at some of the vs. language lock-inJSP technology locks you into a specific language. This point shouldn't be given too much weight. Java technology for enterprise applications (in my opinion, at least) is the only language choice. And there are no language-independent solutions in this space anyway. Of course, at this stage of the game, I'm disregarding the Microsoft .NET platform for the smoke and mirrors it is. Only time will tell whether that platform will develop into one that is truly language-independent. (I'm more than a bit dubious.)Still, choosing JSP technology forces you to use the Java language, at least for presentation and content. While CORBA can be used for business logic, JSP coding does necessitate some familiarity with servlets as well as the core Java language. Since many developers come to JSP coding through the J2EE platform, this doesn't usually present avs. independenceThroughout this article, I've come back to the idea of separating content from presentation. You're probably pretty sick of hearing about this, so now's the time to determine whether or not JSP actually accomplishes this goal. As I've already discussed, JSP claims to have been designed for this separation purpose, and therefore we should assume it achieves its objectives, right? Not the line between content and presentationJSP allows Java code to be inserted into the markup language page, and this rather dangerous feature allows content to be intermingled with presentation. Even worse, business logic often makes its way into JSP pages, as shown in Listing 5.class=displaycode<%@ page import="" %><%@ page import="" %><%@ page import="" %><%@ page import="" %><%@ page import="" %><%@ page import="" %><%PageInfo pageInfo = (PageInfo)("PAGE_DATA")%><HTML><HEAD><TITLE><%=()%></TITLE></HEAD><BODY><H2 ALIGN="center">Search Results: Actors</H2><CENTER><HR width="85%"><TABLE width="50%" CELLPADDING="3" CELLSPACING="3" border="1"BGCOLOR="#FFFFCC"><%asPermission("ADMINISTRATOR")) {actors = ());} else {actors = ();}for (Iterator i = (); ()) {Actor actor = (Actor)();%><TR BGCOLOR="#FFCCCC"><TH width="50%" ALIGN="center"><%=()%></TH><TH width="50%" ALIGN="center"><%=()%></TH></TR><%}%></TABLE></CENTER></BODY></HTML>JSP advocates are quick to let you know that JSP tag libraries can help you avoid this problem. Tag libraries allow custom tags (for example, <AUTHORS />) to be added to a JSP page, which at runtime are resolved intocode fragments in, well, tag use of a custom tag and associated tag library would allow the example above to be converted to that shown in Listing 6.class=displaycode<CENTER><TABLE width="50%" CELLPADDING="3" CELLSPACING="3" border="1"BGCOLOR="#FFFFCC"><ACTORS /></TABLE></CENTER>At runtime, the code for this tag executes and the correct results are inserted into the page. But this does not solve the problem. The argument against JSP technology is not whether content and presentation can be separated, but whether they must be separated. As long as JSP coding allows inline coding, it is very convenient (especially when deadlines are looming) to make last-minute changes with inline code, rather than converting the code to a tag library. If this doesn't ring true, consider why the Java language immediately gained popularity over C and C++: Java disallowed many of the features that were problematic in C, such as pointer addition. While you can always argue that you don't have to perform pointer addition in C or that no good programmer would ever insert code scriptlets, we all know what happens in practice. The Java language is a better language because it mandates that these sorts of bad habits never surface. But JSP in this case is much like C, allowing some very bad additional litmus test of the JSP technology's success in meeting its stated objectives is to see whether or not it is possible to achieve this goal in practice; certainly it isn't fair to hold JSP to an impossible standard. Most template engines, like FreeMarker and WebMacro, have this same inline coding facility, often with a Perl-analogue language. However, technologies like Enhydra's XMLC do not allow this type of inline coding.Instead, these technologies take a pure markup language page as input, and generate Java methods. This essentially is changing the program flow; instead of the page (JSP technology) calling logic from the application, the application (Enhydra) uses methods to affect the values of the page. In the specific case of Enhydra, XMLC converts the page into a DOM tree, and uses the DOM's HTML binding to allow "fields" in the page to be updated. The point here is that more so than XMLC, JSP technology can achieve its goals, by only allowing tag libraries, for example. But the general tendency in Sun specifications is to always maintain backward compatibility, or at least maintain it for quite a long time. The current version of the JSP spec, , allows scriptlets, so expect to see code allowed in JSP pages for several years to come. Before diving into JSP coding, be careful of the rather large hole that lies between its ideal, a complete separation of content and presentation, and what it actually provides, which is at best a pseudo-split between your user interface and the code that drives your application.Single-processing vs. multi-taskingIdeally, as discussed above, a designer ought to be able to perform a single process, working purely on graphic design, and a developer should be able to focus purely on coding. So the designer should be able to work on a page after it has been converted to an application-suitable format. In the case of a JSP page, that would be after JavaBeans have been imported, inline coding has been inserted, and custom tag libraries have been added to the page. The problem is that some designers use HTML editors, such as HoTMetaL, Macromedia Dreamweaver, or FrontPage, that do not recognize code scriptlets or tag libraries, which means the designer effectively receives only a partial page. Imagine the difficulties when tag libraries or code fragments generate rows of a table, or other formatting detailsfor the page. Designers using the incompatible HTML editors can't see what those elements look like. When designers can't easily revise pages after developers finish coding them, instead of clarifying distinct roles, JSP coding can cause them to merge: a developer must multitask, becoming developer, designer, and about the importance of this feature? Then download the J2EE Reference Implementation and load one of the included JSP pages into a WYSIWYG HTML editor, such as Dreamweaver. The page immediately fills with yellow areas letting you know about all the "illegal" markup contained within the page. Of course, the yellow results from the JSP tags and code, rather than any real error in the date, no JSP-capable WYSIWYG editors exist, and I have not heard of any efforts to build one. While template engines have this same problem, many Java-based solutions, such as my favorite, Enhydra, allow you to supply the markup page as input to the presentation technology. In this case, the designer can make changes as often as needed and resupply the markup page. Running the engine or compiler for the presentation technology converts it to the proper format, and no code changes have to be made (in the typical case). The result is the desired one: designers remain designers, and developers remain , be wary of the promise of JSP technology as compared to the reality of what it delivers. In practice, to function in a JSP technology-driven environment you must either have your developers handle a large portion of the markup or have designers learn at least some JSP vs. XMLOne of the most significant disadvantages of JSP technology, and one of the most overlooked, is its incompatibility with XML. More precisely, and particularly in the HTML realm, JSP pages are not required to be XHTML-compatible. XHTML is a World Wide Web Consortium (W3C) specification that is now replacing HTML . XHTML defines the HTML tagset in terms of a well-formed XML document. For example, the <br> tag must be converted to <br/> to ensure XML compliance. Similar rulesare applied to image tags, and in XHTML (recently coming of age) most font properties and other styling move into CSS stylesheets. Still, most standard HTML documents convert easily to XHTML , which means they can be read directly with any XML-compliant parser, such as Apache Xerces, and manipulated as XML."What's the big deal?" you ask. The big deal is that XML quickly is becoming the global standard for inter- and intra-application communication. Passing data around in an XML format lets any other application that employs basic XML data-handling facilities use your application's data easily. Imagine being able to communicate with credit card companies for e-commerce simply by moving your data into an XML format! Many times, your presentation of data needs to be exchanged with other companies as well. The most common case is the portal application, which receives content from a variety of providers (weather, stock quotes, and news, for example), often with branding from the provider. JSP pages, however, with their mix of code and custom tag libraries, cannot function well in this pages are rarely well-formed XML documents, never mind conforming to XHTML, a markup language that doesn't allow the various JSP custom tag libraries. More important, though, is that the code snippets inserted in JSP pages are not any form of markup and will create loads of parser errors once they are processed by another you go quoting me on this, let's get the whole story out there. If the application were to allow the JSP page to be evaluated by the original client, the result would be pure HTML (or WML, VoXML, and so on). Most applications that request this data, however, employ some form of caching, as network round-trips are very expensive. In these cases, the cached page returns stale data. In those cases, then, you'd probably prefer to return pure XML-compliant results, preferably in a static form. And it is in those cases that JSP technology cannot help; JSP pages must always be evaluated at runtime to remove the JSP code scriptlets and tag the litmus test:。
JSP技术简介及特点(外文文献译文)
JSP Technology Conspectus and SpecialtiesThe JSP (Java Server Pages) technology is used by the Sun micro-system issued by the company to develop dynamic Web application technology. With its easy, cross-platform, in many dynamic Web application programming languages, in a short spa n of a few years, has formed a complete set of standards, and widely used in electr onic commerce, etc. In China, the JSP now also got more extensive attention; get a good development, more and more dynamic website to JSP technology. The related technologies of JSP are briefly introduced.The JSP a simple technology can quickly and with the method of generating W eb pages. Use the JSP technology Web page can be easily display dynamic content. The JSP technology are designed to make the construction based on Web applicati ons easier and efficient, and these applications and various Web server, application server, the browser and development tools work together.The JSP technology isn't the only dynamic web technology, also not the first o ne, in the JSP technology existed before the emergence of several excellent dynami c web technologies, such as CGI, ASP, etc. With the introduction of these technolo gies under dynamic web technology, the development and the JSP. Technical JSP the development background and development historyIn web brief history, from a world wide web that most of the network informati on static on stock transactions evolution to acquisition of an operation and infrastru cture. In a variety of applications, may be used for based on Web client, look no res trictions.Based on the browser client applications than traditional based on client/server applications has several advantages. These benefits include almost no limit client a ccess and extremely simplified application deployment and management (to update an application, management personnel only need to change the program on a serve r, not thousands of installation in client applications). So, the software industry is r apidly to build on the client browser multilayer application.The rapid growth of exquisite based Web application requirements developme nt of technical improvements. Static HTML to show relatively static content is righ t choice, the new challenge is to create the interaction based on Web applications, i n these procedures, the content of a Web page is based on the user's request or the state of the system, and are not predefined characters.For the problem of an early solution is to use a CGI - BIN interface. Developer s write to interface with the relevant procedures and separate based on Web applica tions, the latter through the Web server to invoke the former. This plan has serious problem -- each new extensible CGI requirements in a new process on the server. I f multiple concurrent users access to this procedure, these processes will use the W eb server of all available resources, and the performance of the system will be redu ced to extremely low.Some Web server providers have to provide for their server by plugins "and" th e API to simplify the Web application development. These solutions are associated with certain Web server, cannot solve the span multiple suppliers solutions. For exa mple, Microsoft's Active Server mix (ASP) technology in the Web page to create d ynamic content more easily, but also can work in Microsoft on Personal Web Serve r and IIS.There are other solutions, but cannot make an ordinary page designers can easi ly master. For example, such as the Servlet Java technologies can use Java languag e interaction application server code easier. Developers to write such Servlet to rec eive signals from the Web browser to generate an HTTP request, a dynamic respon se (may be inquires the database to finish the request), then send contain HTML or XML documents to the response of the browser.Note: one is based on a Java Servlet Java technical operation in the server pro gram (with different, the latter operating in the Applet browser end). In this book th e Servlet chapter .Using this method, the entire page must have made in Java Servlet. If develope rs or Web managers want to adjust page, you'll have to edit and recompile the Servl et Java, even in logic has been able to run. Using this method, the dynamic content with the application of the page still need to develop skills.Obviously, what is needed is a industry to create dynamic content within the sc ope of the pages of the solution. This program will solve the current scheme are li mited. As follows:can on any Web server or applications. will application page displays and separation. can rapidly developing and testing.simplify the interactive development based on Web application process. TheJSP technology is designed to meet such requirements. The JSP specification is a Web server, application server, trading system and develops extensive cooperation between the tool suppliers. From this standard to develop the existing integration a nd balance of Java programming environment (for example, Java Servlet and Java Beans) support techniques and tools. The result is a kind of new and developing m ethod based on Web applications, using component-based application logic page de signers with powerful functions.Overall Semantics of a JSP PageA JSP page implementation class defines a JSP Service () method mapping fro m the request to the response object. Some details of this transformation are specifi c to the scripting language used (see Chapter JSP.9, “Scripting”). Most details are n ot language specific and are described in this chapter.The content of a JSP page is devoted largely to describing the data that is writt en into the output stream of the response. (The JSP container usually sends this dat a back to the client.) The description is based on a JSP Writer object that is expose d through the implicit object out (see Section JSP.1.8.3, “Implicit Objects”). Its val ue varies:Initially, out is a new JSP Writer object. This object may be different from the stream object returned from response, get Writer (), and may be considered to be in terposed on the latter in order to implement buffering (see Section JSP.1.10.1, “The page Directive”). This is the initial out object. JSP page authors are prohibited fro m writing directly to either the Print Writer or Output Stream associated with the S ervlet Response.The JSP container should not invoke response.get Writer () until the time when the first portion of the content is to be sent to the client. This enables a number of uses of JSP, including using JSP as a language to “glue” actions that deliver binary content, or reliably forwarding to a Servlet, or change dynamically the content type of the response before generating content. See Chapter JSP.4, “Internationalization Issues”.Within the body of some actions, out may be temporarily re-assigned to a diffe rent (nested) instance of a JSP Writer object. Whether this is the case depends on th e details of the action’s semantics. Typically the content of these temporary streams is appended to the stream previously referred to by out, and out is subsequently re-assigned to refer to the previous (nesting) stream. Such nested streams are always b uffered, and require explicit flushing to a nesting stream or their contents will be di scarded.If the initial out JSP Writer object is buffered, then depending upon the value o f the auto-Flush attribute of the page directive, the content of that buffer will either be automatically flushed out to the Servlet Response output stream to obviate overf low, or an exception shall be thrown to signal buffer overflow. If the initial out JSP Writer is unbuffered, then content written to it will be passed directly through to th e Servlet Response output stream.A JSP page can also describe what should happen when some specific events o ccur. In JSP 2.1, the only events that can be described are the initialization and the destruction of the page. These events are described using “well-known method na mes” in declaration elements..JavaScript is used for the first kind is browser, the dynamic general purpose of client scripting language. Netscape first proposed in 1995, but its JavaScript Live S cript called. Then quickly Netscape Live Script renamed JavaScript, Java develope rs with them from the same issued a statement. A statement Java and JavaScript wil l complement each other, but they are different, so the technology of the many dis missed the misunderstanding of the two technologies.JavaScript to create user interface control provides a scripting language. In fact , in the browser into the JavaScript code logic. It can support such effect: when the cursor on the Web page of a mobile user input validation or transform image.Microsoft also writes out their JavaScript version and the JSP script called. Mi crosoft and Netscape support JavaScript and JSP script around core characteristics and European Manufacturers is made by (ECMA) standards organization, the contr ol standard of scripting language. ECMA its scripting language ECMAScript name d.Servlets and JSP often include fragments of information that are common to an organization, such as logos, copyrights, trademarks, or navigation bars. The web a pplication uses the include mechanisms to import the information wherever it is ne eded, since it is easier to change content in one place then to maintain it in every pi ece of code where it is used. Some of this information is static and either never or r arely changes, such as an organization's logo. In other cases, the information is more dynamic and changes often and unpredictably, such as a textual greeting that mus t be localized for each user. In both cases, you want to ensure that the servlet or JS P can evolve independently of its included content, and that the implementation of the servlet or JSP properly updates its included content as necessary.You want to include a resource that does not change very much (such as a page fragment that represents a header or footer) in a JSP. Use the include directive in t he including JSP page, and give the included JSP segment a JSP extension.You want to include content in a JSP each time it receives a request, rather tha n when the JSP is converted to a servlet. Use the JSP: include standard action.You want to include a file dynamically in a JSP, based on a value derived from a configuration file. Use the JSP: include standard action. Provide the value in an external properties file or as a configuration parameter in the deployment descripto r.You want to include a fragment of an XML file inside of a JSP document, or in clude a JSP page in XML syntax. Use the JSP: include standard action for the inclu des that you want to occur with each request of the JSP. Use the JSP: directive.incl ude element if the includes action should occur during the translation phase.You want to include a JSP segment from outside the including file's context. U se the c: importThe operation principle and the advantages of JSP tagsIn this section of the operating principle of simple introduction JSP and strengt hs.For the first time in a JSP documents requested by the engine, JSP Servlet is tr ansformed into a document JSP. This engine is itself a Servlet. The operating proce ss of the JSP shown below:(1) The JSP engine put the JSP files converting a Java source files (Servlet), if you find the files have any grammar mistake JSP, conversion process will interrupt, and to the server and client output error messages.(2) If converted, with the engine JSP Java source file compiler into a correspon ding scale-up files.(3) To create a Servlet (JSP page), the transformation of the Servlet JSP Init () method was executed, JSP Init () method in the life cycle of Servlet executed only once.(4) JSP Service () method invocation to the client requests. For each request, J SP engine to create a new thread for processing the request. If you have multiple cl ients and request the JSP files, JSP engine will create multiple threads. Each client requests a thread. To execute multi-thread can greatly reduce the requirement of sy stem resources, improving the concurrency value and response time. But also shoul d notice the multi-thread programming, due to the limited Servlet always in respon se to memory, so is very fast.(5) If the file has been modified. The JSP, server will be set according to the do cument to decide whether to recompile, if need to recompile, will replace the Servl et compile the memory and continue the process.(6) Although the JSP efficiency is high, but at first when the need to convert and compile and some slight delay. In addition, if at any time due to reasons of syste m resources, JSP engine will in some way of uncertain Servlet will remove from m emory. When this happens JSP Destroy () method was first call.(7) And then Servlet examples were marked with "add" garbage collection. Bu t in JSP Init () some initialization work, if establish connection with database, or to establish a network connection, from a configuration file take some parameters, su ch as, in JSP Destroy () release of the corresponding resources.Based on a Java language has many other techniques JSP page dynamiccharacteristics, technical have embodied in the following aspects:One. Simplicity and effectivenessThe JSP dynamic web pages with the compilation of the static HTML pages of writing are very similar. Just in the original HTML page add JSP tags, or some of t he proprietary scripting (this is not necessary). So, a familiar with HTML page writ e design personnel may be easily performed JSP page development. And the devel opers can not only, and write script by JSP tags used exclusively others have writte n parts to realize dynamic pages. So, an unfamiliar with the web developers scripti ng language, can use the JSP make beautiful dynamic pages. And this in other dyna mic web development is impossible.Tow. The independence of the programThe JSP are part of the family of the API Java, it has the general characteristics of the cross-platform Java program. In other words, is to have the procedure, name ly the independence of the platform, 6 Write bid anywhere!Three. Procedures compatibilityThe dynamic content can various JSP form, so it can show for all kinds of cust omers, namely from using HTML/DHTML browser to use various handheld wirele ss equipment WML (for example, mobile phones and PDA), personal digital equip ment to use XML applications, all can use B2B JSP dynamic pages.Four. Program reusabilityIn the JSP page can not directly, but embedded scripting dynamic interaction w ill be cited as a component part. So, once such a component to write, it can be repe ated several procedures, the program of the reusability. Now, a lot of standard Java Beans library is a good example.JSP technology strengthTime to prepare, run everywhere. At this point Java better than PHP, in additio n to systems, the code not to make any changes.(2) The multi-platform support. Basically on all platforms of any development environment, in any environment for deployment in any environment in the expans ion. Compared ASP / PHP limitations are obvious.(3) A strong scalability. From only a small Jar documents can run Servlet JSP, t o the multiple servers clustering and load balancing, to multiple Application for tra nsaction processing, information processing, a server to numerous servers, Java sh ows a tremendous Vitality.(4) Diversification and powerful development tools support. This is similar to t he ASP, Java already has many very good development tools, and many can be free , and many of them have been able to run on a variety of platforms under.JSP technology vulnerable:(1) And the same ASP, Java is the advantage of some of its fatal problem. It is precisely because in order to cross-platform functionality, in order to extreme stretc hing capacity, greatly increasing the complexity of the product.(2) Java's speed is class to complete the permanent memory, so in some cases by the use of memory compared to the number of users is indeed a "minimum cost performance.”On the other hand, it also needs disk space to store a series of. Java d ocuments and. Class, as well as the corresponding versions of documents.Know servlets for four reasons:1. JSP pages get translated into servlets. You can't understand how JSP workswithout understanding servlets.2. JSP consists of static HTML, special-purpose JSP tags, and Java code. What kind of Java code? Servlet code! You can't write that code if you don't understand servlet programming.3. Some tasks are better accomplished by servlets than by JSP. JSP is good at g enerating pages that consist of large sections of fairly well structured HTML or oth er character data. Servlets are better for generating binary data, building pages with highly variable structure, and performing tasks (such as redirection) that involve li ttle or no output.4. Some tasks are better accomplished by a combination of servlets and JSP th an by either servlets or JSP alone.Versus JavaScriptJavaScript, which is completely distinct from the Java programming language, is normally used to dynamically generate HTML on the client, building parts of the Web page as the browser loads the document. This is a useful capability and does not normally overlap with the capabilities of JSP (which runs only on the server). J SP pages still include SCRIPT tags for JavaScript, just as normal HTML pages do. In fact, JSP can even be used to dynamically generate the JavaScript that will be se nt to the client. So, JavaScript is not a competing technology; it is a complementar y one.JSP is by no means perfect. Many people have pointed out features that could be improved. This is a good thing, and one of the advantages of JSP is that the spec ification is controlled by a community that draws from many different companies. So, the technology can incorporate improvements in successive releases.However, some groups have developed alternative Java-based technologies to t ry to address these deficiencies. This, in our judgment, is a mistake. Using a third-p arty tool like Apache Struts that augments JSP and servlet technology is a good ide a when that tool adds sufficient benefit to compensate for the additional complexity . But using a nonstandard tool that tries to replace JSP is a bad idea. When choosin g a technology, you need to weigh many factors: standardization, portability, integr ation, industry support, and technical features. The arguments for JSP alternatives have focused almost exclusively on the technical features part. But portability, stan dardization, and integration are also very important. For example, the servlet and JSP specifications define a standard directory structure for Web applications and pro vide standard files (.war files) for deploying Web applications. All JSP-compatible servers must support these standards. Filters can be set up to apply to any number o f servlets or JSP pages, but not to nonstandard resources. The same goes for Web a pplication security settings.JSP技术简介及特点JSP(Java Server Pages)技术是由Sun公司发布的用于开发动态Web应用的一项技术。
JSP技术英文简介
Introduction of JSP TechnologyJavaServer PagesTM (jsp (SUN enterprise application of choice)) technology for the creation of display content dynamically generated Web page provides a simple and rapid method. jsp (SUN enterprise application of choice) technology is designed to enable structure-based Web applications more easily and faster, and can these applications with a variety of Web servers, application servers, browsers, and development tools to work together.Here provides a jsp (SUN enterprise application of choice) technology overview, describes the background of its development, as well as the overall objective of this technology. At the same time, a simple example, also describes a JavaTM technology-based key component of the page. Web application development of JavaServer Pages technology WaysIn the development of jsp (SUN enterprise application of choice) specification process, Sun Microsystems (Sun Microsystems Inc.) And many major Web servers, application servers and development tools providers, as well as a variety of experienced development groups to cooperate. The result is found a page for applications and developers to balance the portability and ease of use of development methodologies.Will generate and display the contents of the separationUsing jsp technology, Web page developers can use HTML or xml logo to design and formatting the final page. Jsp logo or the use of bound feet would have to generate dynamic content on the page. The logic-generated content has been packaged in a logo and JavaBeans components and tied up in a small script, all the scripts in the server-side run. If the core logic was encapsulated in the logo and Beans, then other people, such as management and Web page designers, can edit and use jsp pages, without affecting the generation of content.The server side, jsp engine explained jsp logo and small script to generate the requested content (for example, by accessing JavaBeans components, the use of technology JDBCTM access the database, or include file), and the results to HTML (or xml) page of the form sent back to the browser. This helps the author to protect their code, and ensure that any HTML-based Web browser completely availability.Emphasis on reusable componentsJsp page relies on the vast majority of reusable, cross-platform components (JavaBeans or Enterprise JavaBeansTM components) to implement the requirements of applications more complex treatment. Developers to be able to share and exchange components to perform common operations, or make these components more user or client groups to use. Component-based approach to accelerate the overall development process, and make a variety of organizations in their existing skills and to optimize the results of development efforts in the balance.Used to simplify page development logoWeb page developers are not familiar with the scripting language of the programmer. JavaServer Page technology packages a number of functions, which are in use with the jsp-related xml logo in dynamic content generation needs. Jsp logo standards can access and instantiate JavaBeans components, set or retrieve components of property, download Applet, and implementation by other means more difficult to encode and time-consuming function.Through the development of customized logos library, jsp technology can be extended. In future, third-party developers and other personnel for commonly used features to create your ownlogo library. This allows Web page developers can use familiar tools and the same logo as the implementation of specific functions of components to work.jsp technology easily integrated into a variety of applications architecture, to take advantage of existing tools and techniques, and expanded to be able to support enterprise-class distributed applications. The use of Java technology as part of the family, as well as the Java 2 (Enterprise Architecture) is an integral part of, jsp technology can support the highly complex Web-based applications.Jsp page because of the built-scripting language is based on the Java programming language, and all the jsp pages are compiled to become Java Servlet, jsp page on with all the benefits of Java technology, including robust storage management and security.As part of Java Platform, jsp has a Java programming language, "write once, run everywhere" characteristics. As more and more suppliers will be added to jsp support their products, you can use your own choice of server and tools, change tools, or the server does not affect the current application.When used with Java 2 Platform, Enterprise Edition (J2EE) and Enterprise JavaBean technology integration, jsp page will provide enterprise-class scalability and performance, which is essential for the deployment of virtual enterprise Web-based applications is essential.jsp instructionsjsp page using jsp direct instruction delivered to the jsp engine. This includes:jsp page directives related to information transmission page, such as buffer and thread information or wrong treatment.Language instructions specified scripting language, as well as all the expansion.Contains instructions (in the above examples have shown) can be used in the page that contains an external document. A good example is the copyright or company information documents documents - in a centralized location to preserve the document and the page contains more than in all jsp page should be easier to update. Of course, being contained in a document may also be another jsp file.Logo library instructions pointed out that the page can call a client logo library.jsp logoWill deal with the overwhelming majority of jsp and jsp related xml based on the completion of the logo. jsp 1.0 contains substantial standard logo, which identifies as a core identity, including:jsp: useBean statement of the identity of a component instance of the use of JavaBeans. If the component instance does not exist, JavaBeans components to instantiate and register the logo.jsp: setProperty this logo set up examples of components of a property's value.jsp: getProperty this logo to obtain a component instance of the property value, will be translated into a string, and place it implied object "out" Medium.jsp:includejsp:forwardThe merit of their logo in the application easy to use and share. Grammar based on the logo of the real power comes from the customer identification library development, makes a tool supplier or other personnel can request a specific assignment to create and logo.Script componentsjsp page in the page that contains a small script, called the small script (scriptlets). Small scriptis a code fragment, in the request processing is executed. Small scripts can be a static page element (as the same as the above example) to create dynamically generated pages.Script in the <% and%> signs have been described. Signs in this for all the things are described scripting language engine implementation, in our case are the host of the Java Virtual Machinejsp specification support all commonly used script component, including regular expressions and statements.jsp page application modeljsp page from the implementation of js engine, engines installed in the Web server or application using jsp server. jsp engine to accept the client request to the jsp page, and generate jsp pages to the client's response.jsp pages are usually compiled become a Java Servlet. The latter is a standard Java extension in site has more detailed description. Page developers can access all of the Java application environment to take advantage of Java technology, scalability and portability.When the first jsp page is called, if it does not exist, will be compiled into a Java Servlet category, and is stored in the server's memory. This makes the next call to the page have a very quick response.jsp page can be included in a wide variety of application architecture or model. jsp page can be used by different protocols, components and format of the composition of the Commonwealth. The following sections describe some of the possible consequences.A simple applicationIn a simple implementation, the browser directly call jsp page, jsp page itself generate the requested content (may be called directly from the JDBC database access to information). jsp page can call the JDBC or Java BlendTM component to generate the results, and create a standard HTML, as a result sent back to the browser.The model is basically used jsp page (compilers become Java Servlet) instead of the concept of CGI-BIN. This method has the following advantages:Simple and fast programmingPage authors can easily and resources of state, upon request, to generate dynamic contentThis structure in many applications a good job, but should not be extended to a large number of concurrent Web-based customer access scarce corporate resources, since each client must be set up or share a resource that can be used to connect the content. For example, if the jsp page to access the database, may generate much connection to the database, which will affect the database performance.The use of a flexible Java Servlet ApplicationIn another possible configuration, Web-based client may be directly on the Java Servlet requests, Servlet to generate dynamic content, the results tied to a results object and call jsp page. jsp page to access the object from the dynamic content, and the results (such as HTML) sent back to the browser.This method to create more applications can be shared between reusable components and applications can be used as part of a bigger completed. However, in the same deal with databases such as Enterprise Resource Connection, the scalability problem still exists.JavaBean technology using enterprise-class scalability treatmentjsp page can be used as Enterprise JavaBean (EJB) architecture, a middle layer. In this case, jsp pages and the back-end resources through EJB components interact.EJB components on the back-end management of resources to visit, so as a large number of concurrent users with scalable performance. For e-commerce or other applications, EJB management transactions and potential safety. This will simplify the jsp page. The model for the Java 2 Enterprise Edition (J2EE) platform support.jsp page with the xml technology integrationjsp page can be used to generate the xml and the HTML page.For a simple xml generated, developers can include jsp page xml logo and part of the static template. Dynamic xml generation, the use of server-based objects and generate the output xml client identifier.jsp page with the xml tools are not incompatible. Although the Sun in the design specification when jsp page jsp makes even manual for creators is also very easy, jsp specification also provides a mechanism to facilitate the creation of an arbitrary jsp page xml version. In this way, xml tool to be able to create and operate jsp page.By jsp convert logo and components compatible with the xml equivalent, you can use xml-based tools to operate the jsp page. For example, the script can be included in the <% and%> in, or based on the xml logo <jsp:scriptlet> and </ jsp: scriptlet> Medium. In fact, after following a few simple jsp page will be converted to xml pages are possible, these steps include:Adding a root element jspComponents and instructions will be converted to xml and other objects of compatibleFor page in other components (usually non-jsp) create a CDATA elementThrough this method compatible with the xml, create HTML page designers still have a rapidly create dynamic Web pages-to-use environment, meanwhile, xml-based tools and services can be integrated with the jsp page and compatible server and jsp to work together.jsp technology's futurejsp technology has been designed as an open, scalable dynamic Web page set up standards. Developers can use jsp page to create a portable Web applications, in different Web and application servers for the different occasions are running, and whatever the occasion itself and the need for the creation of tools.Through cooperation with leaders of the industry, Sun assurance jsp norms are open and can be transplanted. Can use any client and server platforms, in any place to prepare and deploy them. The future, tools, suppliers and other vendors will be provided for the specialized function of the client logo library to expand the platform functionality.jsp specification version 1.0 is the path to the dynamic Web page generated by an open industry standard method of the first step. Version 1.0 through a core logo sets, implicit objects, and to start creating dynamic Web pages constitutes the basic functions required of the method is basic. Already has a number of Web servers, application server and development tool vendors are adding to their products jsp1.0 support, so that the industry already has the initial, immediate support. Will be completed later in 1999 the 1.1 version of the xml through greater support for identification of customers, as well as integration with J2EE and the expansion of this version. And suppliers may choose to extend and expand the specification in jsp basic, necessary function. jsp engine can support a variety of powerful scripting language and object model. In the industry to expand technological capabilities and the use of jsp at the same time, Sun also promised to guarantee jsp platform and server technology to maintain inter-inherent portability.This article comes from the original link WEB Development Network:Jsp技术简介JavaServer PagesTM(jsp(SUN企业级应用的首选))技术为创建显示内容的动态生成的Web页面提供了一个简单,快速的方法。
JSP技术简介及特点外文翻译
附录AJSP Technology Conspectus And Specialties The JSP (Java Server mix) technology is used by the Sun microsystem issued by the company to develop dynamic Web application technology. With its easy, cross-platform, in many dynamic Web application programming languages, in a short span of a few years, has formed a complete set of standards, and widely used in electronic commerce, etc. In China, the JSP now also got more extensive attention, get a good development, more and more dynamic website to JSP technology. The related technologies of JSP are briefly introduced.The JSP a simple technology can quickly and with the method of generating Web pages. Use the JSP technology Web page can be easily display dynamic content. The JSP technology are designed to make the construction based on Web applications easier and efficient, and these applications and various Web server, application server, the browser and development tools work together.The JSP technology isn't the only dynamic web technology, also not the first one, in the JSP technology existed before the emergence of several excellent dynamic web technology, such as CGI, ASP, etc. With the introduction of these technologies under dynamic web technology, the development and the JSP. TechnicalJSP the development background and development historyIn web brief history, from a world wide web that most of the network information static on stock transactions evolution to acquisition of an operation and infrastructure. In a variety of applications, may be used for based on Web client, look no restrictions.Based on the browser client applications than traditional based on client/server applications has several advantages. These benefits include almost no limit client access and extremely simplified application deployment and management (to update an application, management personnel only need to change the program on a server, not thousands of installation in client applications). So, the software industry is rapidly to build on the client browser multi-layer application.The rapid growth of exquisite based Web application requirements development of technical improvements. Static HTML to show relatively static content is right choice, The new challenge is to create the interaction based on Web applications, in these procedures, thecontent of a Web page is based on the user's request or the state of the system, and are not predefined characters.For the problem of an early solution is to use a CGI - BIN interface. Developers write to interface with the relevant procedures and separate based on Web applications, the latter through the Web server to invoke the former. This plan has serious problem -- each new extensible CGI requirements in a new process on the server. If multiple concurrent users access to this procedure, these processes will use the Web server of all available resources, and the performance of the system will be reduced to extremely low.Some Web server providers have to provide for their server by plugins "and" the API to simplify the Web application development. These solutions are associated with certain Web server, cannot solve the span multiple suppliers solutions. For example, Microsoft's Active Server mix (ASP) technology in the Web page to create dynamic content more easily, but also can work in Microsoft on Personal Web Server and IIS.There are other solutions, but cannot make an ordinary page designers can easily master. For example, such as the Servlet Java technologies can use Java language interaction application server code easier. Developers to write such Servlet to receive signals from the Web browser to generate an HTTP request, a dynamic response (may be inquires the database to finish the request), then send contain HTML or XML documents to the response of the browser.note: one is based on a Java Servlet Java technical operation in the server program (with different, the latter operating in the Applet browser end). In this book the Servlet chapter 4.Using this method, the entire page must have made in Java Servlet. If developers or Web managers want to adjust page, you'll have to edit and recompile the Servlet Java, even in logic has been able to run. Using this method, the dynamic content with the application of the page still need to develop skills.Obviously, what is needed is a industry to create dynamic content within the scope of the pages of the solution. This program will solve the current scheme are limited. As follows: can on any Web server or applications.will application page displays and separation.can rapidly developing and testing.simplify the interactive development based on Web application process.The JSP technology is designed to meet such requirements. The JSP specification is a Web server, application server, trading system and develop extensive cooperation between the tool suppliers. From this standard to develop the existing integration and balance of Java programming environment (for example, Java Servlet and JavaBeans) support techniques and tools. The result is a kind of new and developing method based on Web applications, using component-based application logic page designers with powerful functions.Overall Semantics of a JSP PageA JSP page implementation class defines a _jspService() method mapping from the request to the response object. Some details of this transformation are specific to the scripting language used (see Chapter JSP.9, “Scripting”). Most details are not language specific and are described in this chapter.The content of a JSP page is devoted largely to describing the data that is written into the output stream of the response. (The JSP container usually sends this data back to the client.) The description is based on a JspWriter object that is exposed through the implicit object out (see Section JSP.1.8.3, “Implicit Objects”). Its value varies:Initially, out is a new JspWriter object. This object may be different from the stream object returned from response.getWriter(), and may be considered to be interposed on the latter in order to implement buffering (see Section JSP.1.10.1, “The page Directive”). This is the initial out object. JSP page authors are prohibited from writing directly to either the PrintWriter or OutputStream associated with the ServletResponse.The JSP container should not invoke response.getWriter() until the time when the first portion of the content is to be sent to the client. This enables a number of uses of JSP, including using JSP as a language to “glue” actions that deliver binary content, or reliably forwarding to a servlet, or change dynamically the content type of the response before generating content. See Chapter JSP.4, “Internationalization Issues”.Within the body of some actions, out may be temporarily re-assigned to a different (nested) instance of a JspWriter object. Whether this is the case depends on the details of the action’s semantics. Typically the content of these temporary streams is appended to the stream previously referred to by out, and out is subsequently re-assigned to refer to the previous (nesting) stream. Such nested streams are always buffered, and require explicit flushing to a nesting stream or their contents will be discarded.If the initial out JspWriter object is buffered, then depending upon the value of the autoFlush attribute of the page directive, the content of that buffer will either be automaticallyflushed out to the ServletResponse output stream to obviate overflow, or an exception shall be thrown to signal buffer overflow. If the initial out JspWriter is unbuffered, then content written to it will be passed directly through to the ServletResponse output stream.A JSP page can also describe what should happen when some specific events occur. In JSP 2.1, the only events that can be described are the initialization and the destruction of the page. These events are described using “well-known method names” in declaration elements..JavaScript is used for the first kind is browser, the dynamic general purpose of client scripting language. Netscape first proposed in 1995, but its JavaScript LiveScript called. Then quickly Netscape LiveScript renamed JavaScript, Java developers with them from the same issued a statement. A statement Java and JavaScript will complement each other, but they are different, so the technology of the many dismissed the misunderstanding of the two technologies.JavaScript to create user interface control provides a scripting language. In fact, in the browser into the JavaScript code logic. It can support such effect: when the cursor on the Web page of a mobile user input validation or transform image.Microsoft also write out their JavaScript version and the JScript called. Microsoft and Netscape support JavaScript and JScript around a core characteristics and European Manufacturers is.md by (ECMA) standards organization, the control standard of scripting language. ECMA its scripting language ECMAScript named.Servlets and JSPs often include fragments of information that are common to an organization, such as logos, copyrights, trademarks, or navigation bars. The web application uses the include mechanisms to import the information wherever it is needed, since it is easier to change content in one place then to maintain it in every piece of code where it is used. Some of this information is static and either never or rarely changes, such as an organization's logo. In other cases, the information is more dynamic and changes often and unpredictably, such as a textual greeting that must be localized for each user. In both cases, you want to ensure that the servlet or JSP can evolve independently of its included content, and that the implementation of the servlet or JSP properly updates its included content as necessary.You want to include a resource that does not change very much (such as a page fragment that represents a header or footer) in a JSP. Use the include directive in the including JSP page, and give the included JSP segment a .jspf extension.You want to include content in a JSP each time it receives a request, rather than when the JSP is converted to a servlet. Use the jsp:include standard action.You want to include a file dynamically in a JSP, based on a value derived from a configuration file. Use the jsp:include standard action. Provide the value in an external properties file or as a configuration parameter in the deployment descriptor.You want to include a fragment of an XML file inside of a JSP document, or include a JSP page in XML syntax. Use the jsp:include standard action for the includes that you want to occur with each request of the JSP. Use the jsp:directive.include element if the include action should occur during the translation phase.You want to include a JSP segment from outside the including file's context. Use the c:importThe operation principle and the advantages of JSP tagsIn this section of the operating principle of simple introduction JSP and strengths.For the first time in a JSP documents requested by the engine, JSP Servlet is transformed into a document JSP. This engine is itself a Servlet. The operating process of the JSP shown below:(1) the JSP engine put the JSP files converting a Java source files (Servlet), if you find the files have any grammar mistake JSP, conversion process will interrupt, and to the server and client output error messages.(2) if converted, with the engine JSP javac Java source file compiler into a corresponding scale-up files.(3) to create a the Servlet (JSP page), the transformation of the Servlet jspInit () method was executed, jspInit () method in the life cycle of Servlet executed only once.(4) jspService () method invocation to the client requests. For each request, JSP engine to create a new thread for processing the request. If you have multiple clients and request the JSP files, JSP engine will create multiple threads. Each client requests a thread. To execute multi-thread can greatly reduce the requirement of system resources, improving the concurrency value and response time. But also should notice the multi-thread programming, due to the limited Servlet always in response to memory, so is very fast.(5) if the file has been modified. The JSP, server will be set according to the document to decide whether to recompile, if need to recompile, will replace the Servlet compile the memory and continue the process.(6) although the JSP efficiency is high, but at first when the need to convert and compile and some slight delay. In addition, if at any time due to reasons of system resources, JSP engine will in some way of uncertain Servlet will remove from memory. When this happens jspDestroy () method was first call.(7) and then Servlet examples were marked with "add" garbage collection. But in jspInit () some initialization work, if establish connection with database, or to establish a network connection, from a configuration file take some parameters, such as, in jspDestory () release of the corresponding resources.Based on a Java language has many other techniques JSP page dynamic characteristics, technical have embodied in the following aspects:One simplicity and effectivenessThe JSP dynamic web pages with the compilation of the static HTML pages of writing is very similar. Just in the original HTML page add JSP tags, or some of the proprietary scripting (this is not necessary). So, a familiar with HTML page write design personnel may be easily performed JSP page development. And the developers can not only, and write script by JSP tags used exclusively others have written parts to realize dynamic pages. So, an unfamiliar with the web developers scripting language, can use the JSP make beautiful dynamic pages. And this in other dynamic web development is impossible.Tow the independence of the programThe JSP are part of the family of the API Java, it has the general characteristics of the cross-platform Java program. In other words, is to have the procedure, namely the independence of the platform, 6 Write bided anywhere! .Three procedures compatibilityThe dynamic content can various JSP form, so it can show for all kinds of customers, namely from using HTML/DHTML browser to use various handheld wireless equipment WML (for example, mobile phones and pdas), personal digital equipment to use XML applications, all can use B2B JSP dynamic pages.Four program reusabilityIn the JSP page can not directly, but embedded scripting dynamic interaction will be cited as a component part. So, once such a component to write, it can be repeated several procedures, the program of the reusability. Now, a lot of standard JavaBeans library is a good example.附录BJSP技术简介及特点JSP(Java Server Pages)技术是由Sun公司发布的用于开发动态Web应用的一项技术。
JSP技术概述与应用框架外文翻译毕业设计
国际化与本地化的重要性:提高 用户体验,增强市场竞争力
添加标题
添加标题
添加标题
添加标题
本地化:根据不同国家和地区的 语言和文化环境,对JSP应用进行 定制和优化
国际化与本地化的实现方法:使 用国际化框架,如i18n,进行国 际化和本地化处理
翻译质量要求
准确性:确保翻译内容与原文意思一致,无错译、漏译现象 流畅性:翻译语言通顺,符合目标语言的表达习惯 专业性:翻译内容涉及专业术语,需准确翻译,不得随意更改 格式规范:翻译后的文档格式应与原文保持一致,包括字体、字号、行距等
PART 6
毕业设计流程与规范
选题与开题报告撰写
选题:选择与专 业相关的课题, 确保具有研究价 值和实际意义
特点:Spring MVC具有清晰的分层结构,易于扩展和维护,支持RESTful风格,支持 多种视图技术。
核心组件:Spring MVC的核心组件包括DispatcherServlet、HandlerMapping、 Controller、ViewResolver等。
应用场景:Spring MVC广泛应用于Web开发中,如企业级应用、电子商务、社交网站等。
JSP可以与其他 Java技术(如 Servlet、 JDBC、JNDI等) 无缝集成,实现 强大的Web应 用程序开发。
JSP工作原理
JSP是一种服务器端的Java技术,用于创 建动态网页。
JSP页面由HTML、Java代码和JSP标签组 成。
JSP页面在服务器上被编译成Java Servlet,然后由Servlet引擎执行。
翻译质量:准色等
翻译时间:根据毕业设计进度, 合理安排翻译时间
JSP技术英文简介
Introduction of JSP TechnologyJavaServer PagesTM (jsp (SUN enterprise application of choice)) technology for the creation of display content dynamically generated Web page provides a simple and rapid method. jsp (SUN enterprise application of choice) technology is designed to enable structure-based Web applications more easily and faster, and can these applications with a variety of Web servers, application servers, browsers, and development tools to work together.Here provides a jsp (SUN enterprise application of choice) technology overview, describes the background of its development, as well as the overall objective of this technology. At the same time, a simple example, also describes a JavaTM technology-based key component of the page. Web application development of JavaServer Pages technology WaysIn the development of jsp (SUN enterprise application of choice) specification process, Sun Microsystems (Sun Microsystems Inc.) And many major Web servers, application servers and development tools providers, as well as a variety of experienced development groups to cooperate. The result is found a page for applications and developers to balance the portability and ease of use of development methodologies.Will generate and display the contents of the separationUsing jsp technology, Web page developers can use HTML or xml logo to design and formatting the final page. Jsp logo or the use of bound feet would have to generate dynamic content on the page. The logic-generated content has been packaged in a logo and JavaBeans components and tied up in a small script, all the scripts in the server-side run. If the core logic was encapsulated in the logo and Beans, then other people, such as management and Web page designers, can edit and use jsp pages, without affecting the generation of content.The server side, jsp engine explained jsp logo and small script to generate the requested content (for example, by accessing JavaBeans components, the use of technology JDBCTM access the database, or include file), and the results to HTML (or xml) page of the form sent back to the browser. This helps the author to protect their code, and ensure that any HTML-based Web browser completely availability.Emphasis on reusable componentsJsp page relies on the vast majority of reusable, cross-platform components (JavaBeans or Enterprise JavaBeansTM components) to implement the requirements of applications more complex treatment. Developers to be able to share and exchange components to perform common operations, or make these components more user or client groups to use. Component-based approach to accelerate the overall development process, and make a variety of organizations in their existing skills and to optimize the results of development efforts in the balance.Used to simplify page development logoWeb page developers are not familiar with the scripting language of the programmer. JavaServer Page technology packages a number of functions, which are in use with the jsp-related xml logo in dynamic content generation needs. Jsp logo standards can access and instantiate JavaBeans components, set or retrieve components of property, download Applet, and implementation by other means more difficult to encode and time-consuming function.Through the development of customized logos library, jsp technology can be extended. In future, third-party developers and other personnel for commonly used features to create your ownlogo library. This allows Web page developers can use familiar tools and the same logo as the implementation of specific functions of components to work.jsp technology easily integrated into a variety of applications architecture, to take advantage of existing tools and techniques, and expanded to be able to support enterprise-class distributed applications. The use of Java technology as part of the family, as well as the Java 2 (Enterprise Architecture) is an integral part of, jsp technology can support the highly complex Web-based applications.Jsp page because of the built-scripting language is based on the Java programming language, and all the jsp pages are compiled to become Java Servlet, jsp page on with all the benefits of Java technology, including robust storage management and security.As part of Java Platform, jsp has a Java programming language, "write once, run everywhere" characteristics. As more and more suppliers will be added to jsp support their products, you can use your own choice of server and tools, change tools, or the server does not affect the current application.When used with Java 2 Platform, Enterprise Edition (J2EE) and Enterprise JavaBean technology integration, jsp page will provide enterprise-class scalability and performance, which is essential for the deployment of virtual enterprise Web-based applications is essential.jsp instructionsjsp page using jsp direct instruction delivered to the jsp engine. This includes:jsp page directives related to information transmission page, such as buffer and thread information or wrong treatment.Language instructions specified scripting language, as well as all the expansion.Contains instructions (in the above examples have shown) can be used in the page that contains an external document. A good example is the copyright or company information documents documents - in a centralized location to preserve the document and the page contains more than in all jsp page should be easier to update. Of course, being contained in a document may also be another jsp file.Logo library instructions pointed out that the page can call a client logo library.jsp logoWill deal with the overwhelming majority of jsp and jsp related xml based on the completion of the logo. jsp 1.0 contains substantial standard logo, which identifies as a core identity, including:jsp: useBean statement of the identity of a component instance of the use of JavaBeans. If the component instance does not exist, JavaBeans components to instantiate and register the logo.jsp: setProperty this logo set up examples of components of a property's value.jsp: getProperty this logo to obtain a component instance of the property value, will be translated into a string, and place it implied object "out" Medium.jsp:includejsp:forwardThe merit of their logo in the application easy to use and share. Grammar based on the logo of the real power comes from the customer identification library development, makes a tool supplier or other personnel can request a specific assignment to create and logo.Script componentsjsp page in the page that contains a small script, called the small script (scriptlets). Small scriptis a code fragment, in the request processing is executed. Small scripts can be a static page element (as the same as the above example) to create dynamically generated pages.Script in the <% and%> signs have been described. Signs in this for all the things are described scripting language engine implementation, in our case are the host of the Java Virtual Machinejsp specification support all commonly used script component, including regular expressions and statements.jsp page application modeljsp page from the implementation of js engine, engines installed in the Web server or application using jsp server. jsp engine to accept the client request to the jsp page, and generate jsp pages to the client's response.jsp pages are usually compiled become a Java Servlet. The latter is a standard Java extension in site has more detailed description. Page developers can access all of the Java application environment to take advantage of Java technology, scalability and portability.When the first jsp page is called, if it does not exist, will be compiled into a Java Servlet category, and is stored in the server's memory. This makes the next call to the page have a very quick response.jsp page can be included in a wide variety of application architecture or model. jsp page can be used by different protocols, components and format of the composition of the Commonwealth. The following sections describe some of the possible consequences.A simple applicationIn a simple implementation, the browser directly call jsp page, jsp page itself generate the requested content (may be called directly from the JDBC database access to information). jsp page can call the JDBC or Java BlendTM component to generate the results, and create a standard HTML, as a result sent back to the browser.The model is basically used jsp page (compilers become Java Servlet) instead of the concept of CGI-BIN. This method has the following advantages:Simple and fast programmingPage authors can easily and resources of state, upon request, to generate dynamic contentThis structure in many applications a good job, but should not be extended to a large number of concurrent Web-based customer access scarce corporate resources, since each client must be set up or share a resource that can be used to connect the content. For example, if the jsp page to access the database, may generate much connection to the database, which will affect the database performance.The use of a flexible Java Servlet ApplicationIn another possible configuration, Web-based client may be directly on the Java Servlet requests, Servlet to generate dynamic content, the results tied to a results object and call jsp page. jsp page to access the object from the dynamic content, and the results (such as HTML) sent back to the browser.This method to create more applications can be shared between reusable components and applications can be used as part of a bigger completed. However, in the same deal with databases such as Enterprise Resource Connection, the scalability problem still exists.JavaBean technology using enterprise-class scalability treatmentjsp page can be used as Enterprise JavaBean (EJB) architecture, a middle layer. In this case, jsp pages and the back-end resources through EJB components interact.EJB components on the back-end management of resources to visit, so as a large number of concurrent users with scalable performance. For e-commerce or other applications, EJB management transactions and potential safety. This will simplify the jsp page. The model for the Java 2 Enterprise Edition (J2EE) platform support.jsp page with the xml technology integrationjsp page can be used to generate the xml and the HTML page.For a simple xml generated, developers can include jsp page xml logo and part of the static template. Dynamic xml generation, the use of server-based objects and generate the output xml client identifier.jsp page with the xml tools are not incompatible. Although the Sun in the design specification when jsp page jsp makes even manual for creators is also very easy, jsp specification also provides a mechanism to facilitate the creation of an arbitrary jsp page xml version. In this way, xml tool to be able to create and operate jsp page.By jsp convert logo and components compatible with the xml equivalent, you can use xml-based tools to operate the jsp page. For example, the script can be included in the <% and%> in, or based on the xml logo <jsp:scriptlet> and </ jsp: scriptlet> Medium. In fact, after following a few simple jsp page will be converted to xml pages are possible, these steps include:Adding a root element jspComponents and instructions will be converted to xml and other objects of compatibleFor page in other components (usually non-jsp) create a CDATA elementThrough this method compatible with the xml, create HTML page designers still have a rapidly create dynamic Web pages-to-use environment, meanwhile, xml-based tools and services can be integrated with the jsp page and compatible server and jsp to work together.jsp technology's futurejsp technology has been designed as an open, scalable dynamic Web page set up standards. Developers can use jsp page to create a portable Web applications, in different Web and application servers for the different occasions are running, and whatever the occasion itself and the need for the creation of tools.Through cooperation with leaders of the industry, Sun assurance jsp norms are open and can be transplanted. Can use any client and server platforms, in any place to prepare and deploy them. The future, tools, suppliers and other vendors will be provided for the specialized function of the client logo library to expand the platform functionality.jsp specification version 1.0 is the path to the dynamic Web page generated by an open industry standard method of the first step. Version 1.0 through a core logo sets, implicit objects, and to start creating dynamic Web pages constitutes the basic functions required of the method is basic. Already has a number of Web servers, application server and development tool vendors are adding to their products jsp1.0 support, so that the industry already has the initial, immediate support. Will be completed later in 1999 the 1.1 version of the xml through greater support for identification of customers, as well as integration with J2EE and the expansion of this version. And suppliers may choose to extend and expand the specification in jsp basic, necessary function. jsp engine can support a variety of powerful scripting language and object model. In the industry to expand technological capabilities and the use of jsp at the same time, Sun also promised to guarantee jsp platform and server technology to maintain inter-inherent portability.This article comes from the original link WEB Development Network:JSP技术介绍JavaServer PagesTM (jsp(SUN企业级应用的首选))技术为创建显示动态生成内容的Web 页面提供了一个简捷而快速的方法。
JSP技术概述与应用框架外文翻译
xx大学xx学院毕业设计(论文)外文资料翻译系:专业:班级:姓名:学号:附件: 1.外文资料翻译译文;2.外文原文注:请将该封面与附件装订成册。
附件一:外文资料翻译译文JSP技术概述与应用框架作者: Zambon, Giulio/ Sekler, Michael出处: Springer-Verlag New York IncJava 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的书籍。
一、JSP的好处JSP(Java Server Pages)是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准,其在动态网页的建设中有其强大而特别的功能。
JSP与Microsoft的ASP技术非常相似。
两者都提供在HTML代码中混合某种程序代码、由语言引擎解释执行程序代码的能力。
下面我们简单的对它进行介绍。
JSP页面最终会转换成servler。
因而,从根本上,JSP页面能够执行的任何任务都可以用servler来完成。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
外文原文Overview of JSP Technology and JSP application frameworksAutor: Zambon Giulio/ Sekler MichaelSource: Springer-Verlag New York Inc1.Benefits of JSPJSP 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.Now, this discussion is not to say that you should stop using servlets and use only JSP instead. By no means. Almost all projects will use both. For some requests in your project, you will use servlets. For others, you will use JSP. For still others, you will combine them with the MVC architecture . You want the appropriate tool for the job, and servlets, by themselves, do not complete your toolkit.2.Advantages of JSP Over Competing TechnologiesA number of years ago, Marty was invited to attend a small 20-person industry roundtable discussion on software technology. Sitting in the seat next to Marty was James Gosling, inventor of the Java programming language. Sitting several seats away was a high-level manager from a very large software company in Redmond, Washington. During the discussion, the moderator brought up the subject of Jini, which at that time was a new Java technology. The moderator asked the manager what he thought of it, and the manager responded that it was too early to tell, but that it seemed to be an excellent idea. He went on tosay that they would keep an eye on it, and if it seemed to be catching on, they would follow his company's usual "embrace and extend" strategy. At this point, Gosling lightheartedly interjected "You mean disgrace and distend."Now, the grievance that Gosling was airing was that he felt that this company would take technology from other companies and suborn it for their own purposes. But guess what? The shoe is on the other foot here. The Java community did not invent the idea of designing pages as a mixture of static HTML and dynamic code marked with special tags. For example, ColdFusion did it years earlier. Even ASP (a product from the very software company of the aforementioned manager) popularized this approach before JSP came along and decided to jump on the bandwagon. In fact, JSP not only adopted the general idea, it even used many of the same special tags as ASP did..So, the question becomes: why use JSP instead of one of these other technologies? Our first response is that we are not arguing that everyone should. Several of those other technologies are quite good and are reasonable options in some situations. In other situations, however, JSP is clearly better. Here are a few of the reasons. 2.1 Versus .NET and Active Server Pages (ASP). NET is well-designed technology from Microsoft. is the part that directly competes with servlets and JSP. The advantages of JSP are two fold.First, JSP is portable to multiple operating systems and Web servers; you aren't locked into deploying on Windows and IIS. Although the core .NET platform runs on a few non-Windows platforms, the ASP part does not. You cannot expect to deploy serious applications on multiple servers and operating systems. For some applications, this difference does not matter. For others, it matters greatly.Second, for some applications the choice of the underlying language matters greatly. For example, although .NET's C# language is very well designed and is similar to Java, fewer programmers are familiar with either the core C# syntax or the many auxiliary libraries. In addition, many developers still use the original version of ASP. With this version, JSP has a clear advantage for the dynamic code. With JSP, the dynamic part is written in Java, not VBScript or another ASP-specific language, so JSP is more powerful and better suited to complex applications that require reusable components.You could make the same argument when comparing JSP to the previous version of ColdFusion; with JSP you can use Java for the "real code" and are not tied to a particular server product. However, the current release of ColdFusion is within the context of a J2EE server, allowing developers to easily mix ColdFusion and servlet/JSP code.2.2 Versus PHPPHP (a recursive acronym for "PHP: Hypertext Preprocessor") is a free, open-source, HTML-embedded scripting language that is somewhat similar to both ASP and JSP. Oneadvantage of JSP is that the dynamic part is written in Java, which already has an extensive API for networking, database access, distributed objects, and the like, whereas PHP requires learning an entirely new, less widely used language. A second advantage is that JSP is much more widely supported by tool and server vendors than is PHP.2.3 Versus Pure ServletsJSP doesn't provide any capabilities that couldn't, in principle, be accomplished with servlets. In fact, JSP documents are automatically translated into servlets behind the scenes. But it is more convenient to write (and to modify!) regular HTML than to use a zillion println statements to generate the HTML. Plus, by separating the presentation from the content, you can put different people on different tasks: your Web page design experts can build the HTML by using familiar tools and either leave places for your servlet programmers to insert the dynamic content or invoke the dynamic content indirectly by means of XML tags.Does this mean that you can just learn JSP and forget about servlets? Absolutely not! JSP developers need to know servlets for four reasons:1. JSP pages get translated into servlets. You can't understand how JSP works without understanding servlets.2. JSP consists of static HTML, special-purpose JSP tags, and Java code. What kind of Java code? Servlet code! You can't write that code if you don't understand servlet programming.3. Some tasks are better accomplished by servlets than by JSP. JSP is good at generating pages that consist of large sections of fairly well structured HTML or other character data. Servlets are better for generating binary data, building pages with highly variable structure, and performing tasks (such as redirection) that involve little or no output.4. Some tasks are better accomplished by a combination of servlets and JSP than by either servlets or JSP alone.2.4 Versus JavaScriptJavaScript, which is completely distinct from the Java programming language, is normally used to dynamically generate HTML on the client, building parts of the Web page as the browser loads the document. This is a useful capability and does not normally overlap with the capabilities of JSP (which runs only on the server). JSP pages still include SCRIPT tags for JavaScript, just as normal HTML pages do. In fact, JSP can even be used to dynamically generate the JavaScript that will be sent to the client. So, JavaScript is not a competing technology; it is a complementary one.It is also possible to use JavaScript on the server, most notably on Sun ONE (formerly iPlanet), IIS, and BroadVision servers. However, Java is more powerful, flexible, reliable, and portable.2.5 Versus WebMacro or VelocityJSP is by no means perfect. Many people have pointed out features that could be improved. This is a good thing, and one of the advantages of JSP is that the specification is controlled by a community that draws from many different companies. So, the technology can incorporate improvements in successive releases.However, some groups have developed alternative Java-based technologies to try to address these deficiencies. This, in our judgment, is a mistake. Using a third-party tool like Apache Struts that augments JSP and servlet technology is a good idea when that tool adds sufficient benefit to compensate for the additional complexity. But using a nonstandard tool that tries to replace JSP is a bad idea. When choosing a technology, you need to weigh many factors: standardization, portability, integration, industry support, and technical features. The arguments for JSP alternatives have focused almost exclusively on the technical features part. But portability, standardization, and integration are also very important. For example, the servlet and JSP specifications define a standard directory structure for Web applications and provide standard files (.war files) for deploying Web applications. All JSP-compatible servers must support these standards. Filters can be set up to apply to any number of servlets or JSP pages, but not to nonstandard resources. The same goes for Web application security settings.Besides, the tremendous industry support for JSP and servlet technology results in improvements that mitigate many of the criticisms of JSP. For example, the JSP Standard Tag Library and the JSP 2.0 expression language address two of the most well-founded criticisms: the lack of good iteration constructs and the difficulty of accessing dynamic results without using either explicit Java code or verbose jsp:useBean elements.3. Misconceptions About JSPForgetting JSP Is Server-Side TechnologyHere are some typical questions Marty has received (most of them repeatedly).• Our server is running JDK 1.4. So, how do I put a Swing component in a JSP page?• How do I put an image into a JSP page? I do not know the proper Java I/O commands to read image files.• Since Tomcat does not support JavaScript, how do I make images that are highlighted when the user moves the mouse over them?• Our clients use older browsers that do not understand JSP. What should we do?• When our clients use "View Source" in a browser, how can I prevent them from seeing theJSP tags?All of these questions are based upon the assumption that browsers know something about the server-side process. But they do not. Thus:• For putting applets with Swing components into Web pages, what matters is the browser's Java version—the server's version is irrelevant. If the browser supports the Java 2 platform, you use the normal APPLET (or Java plug-in) tag and would do so even if you were using non-Java technology on the server.• You do not need Java I/O to read image files; you just put the ima ge in the directory for Web resources (i.e., two levels up from WEB-INF/classes) and output a normal IMG tag.• You create images that change under the mouse by using client-side JavaScript, referenced with the SCRIPT tag; this does not change just because the server is using JSP.• Browsers do not "support" JSP at all—they merely see the output of the JSP page. So, make sure your JSP outputs HTML compatible with the browser, just as you would do with static HTML pages.• And, of course you need not do anyt hing to prevent clients from seeing JSP tags; those tags are processed on the server and are not part of the output that is sent to the client. Confusing Translation Time with Request TimeA JSP page is converted into a servlet. The servlet is compiled, loaded into the server's memory, initialized, and executed. But which step happens when? To answer that question, remember two points:• The JSP page is translated into a servlet and compiled only the first time it is accessed after having been modified.• Loading into memory, initialization, and execution follow the normal rules for servlets.The most frequently misunderstood entries are highlighted. When referring to the table, note that servlets resulting from JSP pages use the _jspService method (called for both GET and POST requests), not doGet or doPost. Also, for initialization, they use the jspInit method, not the init method.JSP page translated into servlet Servlet compiled Servlet loaded into server's memory jspInit called _jspService called.4.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 toprovide 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 to provide 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 acro nyms 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 negotiationsfrom 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 for applications 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 locationof 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 serve r 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.5. 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 create dynamic 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].6. 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 withbusiness 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.7. 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 through two flavor s 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 with JavaBeans. 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。