计算机专业外文翻译---jsp应用框架-jsp程序(编辑修改稿)内容摘要:
ry 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 threadsafe. To learn more about servlet programming, we remend 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: (POne line of HTML./P)。 (PAnother line of HTML./P)。 is all too mon in servlets that generate the HTTP response. There are libraries that can help you generate HTML, but as applications grow more plex, 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 bine scripting and templating technologies into a single ponent. 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 piles 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 piled, 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 plete the businesslogic 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 ponents. DEFINITION A JavaBean is a reusable software ponent 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 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 th。计算机专业外文翻译---jsp应用框架-jsp程序(编辑修改稿)
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。