菜单
  

    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].
    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 pide 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.
  1. 上一篇:B/S/Browser/Server结构英文文献和中文翻译
  2. 下一篇:ASP英文参考文献翻译
  1. JSP英文文献和中文翻译

  2. 变频器在供水控制系统的...

  3. Java技术的Web应用设计模型...

  4. JSP技术简介及特点英文文献和中文翻译

  5. JSP技术概述英文文献和中文翻译

  6. Servlet和JSP技术概述英文文献和中文翻译

  7. 冷弯钢门户框架的设计方...

  8. 大众媒体对公共政策制定的影响

  9. 杂拟谷盗体内共生菌沃尔...

  10. 河岸冲刷和泥沙淤积的监测国内外研究现状

  11. 十二层带中心支撑钢结构...

  12. 乳业同业并购式全产业链...

  13. 当代大学生慈善意识研究+文献综述

  14. 酸性水汽提装置总汽提塔设计+CAD图纸

  15. 中考体育项目与体育教学合理结合的研究

  16. java+mysql车辆管理系统的设计+源代码

  17. 电站锅炉暖风器设计任务书

  

About

751论文网手机版...

主页:http://www.751com.cn

关闭返回