Java servlets are server-side Java programs that generate content in response to a client request. Servlets can be thought of as applets that run on the server side without a user interface. Servlets are invoked through URL invocation or by other servlets.
Sun Java System Web Server 7.0 supports the Java Servlet 2.5 specification.
Java Servlet API version 2.5 is fully backward compatible with versions 2.1, 2.2, 2.3, and 2.5. Therefore, all existing servlets continues to work without modification or recompilation.
To develop servlets, use Sun's Java Servlet API. For information about using the Java Servlet API, see the documentation provided by Sun at http://java.sun.com/products/servlet/index.html.
For the Java Servlet 2.5 specification, see http://java.sun.com/products/servlet/download.html.
For information about developing servlets in Sun Java System Web Server, see Chapter 4, Developing Servlets
Web Server 7.0 supports the JavaServer Pages (JSP) 2.1 specification. A JSP page is, much like an HTML page, that can be viewed in a web browser. However, in addition to HTML tags, JSP can include a set of JSP tags and directives intermixed with Java code that extend the ability of the web page designer to incorporate dynamic content in a page. These additional features provide functionality such as displaying property values and using simple conditionals.
JSP pages can access full Java functionality using the following methods:
Embedding Java code directly into scriptlets
Using server-side tags that include Java servlets
Servlets are Java classes that must be compiled. Servlets can be defined and compiled by a Java programmer, who then publishes the interface to the servlet. The web page designer can access a precompiled servlet from a JSP page. For information about creating JSPages, see http://java.sun.com/products/jsp/index.html
The Java Server Pages Standard Tag Library (JSTL) encapsulates as simple tags the core functionality common to many web applications. JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags. It also provides a framework for integrating existing custom tags with JSTL tags.
For more information on JSTL 1.2, see http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL.html#wp74644.
Web Services uses a Web Services Description Language (WSDL) file to describe the service and a registry service to register and lookup the services. The Simple Object Access Protocol (SOAP) binding is the standard interoperable binding for accessing Web Services. Based on Java Web Services Developer Pack (Java WSDP), Web Server supports integrated Java Web Services runtime and tools, and therefore supports portable Web Services implementations. For more information, see Chapter 3, Web Services Overview.
Web Server 7.0 provides Java Naming and Directory InterfaceTM (JNDI) API support that enables web applications to look up for Java Enterprise Edition (Java EE) services such as Java DataBase Connectivity (JDBCTM) data sources. All functional aspects of this JNDI implementation are essential. However, the web server's implementation does not support the CosNaming service required for remote objects as well as lookup of UserTransaction, ORB, JMS resources, or the EJB references.
In Web Server, JDBCRESOURCE and JDBCCONNECTIONPOOL elements in server.xml have been merged into one element called jdbc-resource to simplify JDBC configuration. Many of the configuration parameters have been renamed. For more information on the jdbc-resource element, see Chapter 3, Elements in server.xml, in Sun Java System Web Server 7.0 Update 4 Administrator’s Configuration File Reference.
Using JNDI, a web application can access a JDBC connection pool by looking up the jdbc-resource that configures it. The jdbc-resources can access the name in its web descriptor. The following web descriptors example refer to the connection pool created in the earlier example.
<web-app> ... <resource-ref> <description>JDBC Connection Pool</description> <res-ref-name>jdbc/myJdbc</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> ... </web-app>
<sun-web-app> ... <resource-ref> <res-ref-name>jdbc/myJdbc</res-ref-name> <jndi-name>jdbc/MyPool</jndi-name> </resource-ref> ... </sun-web-app>
In the above example, jdbc/myJdbc is the name by which the pool is referenced in the web application and jdbc/MyPool is the JNDI name of the jdbc-resources configuration.
The following is an example for using the pool in a web application.
Context initContext = new InitialContext(); Context webContext = (Context)initContext.lookup("java:/comp/env"); DataSource ds = (DataSource) webContext.lookup("jdbc/myJdbc"); Connection dbCon = ds.getConnection();