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 inpidualized request from a browser。

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]。

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 be

public 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。

上一篇:Java编程语言英文文献和中文翻译
下一篇:校园宿舍管理系统英文文献和中文翻译

JUC同步框架英文文献和中文翻译

碳化硅电器元件的应用英文文献和中文翻译

数字通信技术在塑料挤出...

改善重型SCR系统的应用程...

CAE技术在车辆安全性应用英文文献和中文翻译

MySQL和JSP的Web应用程序英文文献和中文翻译

C#的应用英文文献和中文翻译

我国风险投资的发展现状问题及对策分析

网络语言“XX体”研究

张洁小说《无字》中的女性意识

老年2型糖尿病患者运动疗...

安康汉江网讯

ASP.net+sqlserver企业设备管理系统设计与开发

互联网教育”变革路径研究进展【7972字】

LiMn1-xFexPO4正极材料合成及充放电性能研究

麦秸秆还田和沼液灌溉对...

新課改下小學语文洧效阅...