Sun Java System Web Server 7.0 Update 2 Developer's Guide to Java Web Applications

Chapter 1 Web Server Technologies Overview

This chapter provides a basic overview on various technologies that are supported in the Web Server.

Technologies and Enhancements in Web Server 7.0

Web Server is a major new release with significant enhancements in the administration infrastructure. This release is the first 64-bit version of Web Server supported on Solaris SPARC®, AMD64 and Linux platforms.

Web Server 7.0 provides:

This product also comes with a robust built-in migration tool that helps migrate applications and configurations from Web Server 6.0 and 6.1 to Sun Java System Web Server 7.0.

Sun Java System Web Server 7.0 introduces the following new features:

For more features and information, see What’s New in This Release in Sun Java System Web Server 7.0 Update 2 Release Notes.

Supported Standards, Protocols, and Technologies

Servlet 2.5 Support

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.


Note –

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

JSP 2.1 Support

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:

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

JSTL 1.2

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.

Java Web Services Developer Pack 2.0 Support

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.

JNDI Naming

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.

JDBC Connection Pooling

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 2 Administrator’s Configuration File Reference.

Using JNDI to Access the jdbc-resource Within a Web Application

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-INF/web.xml

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

WEB-INF/sun-web.xml

<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();

Tools Support

Web Server 7.0 provides support for the following tools:

Lifecycle Listeners and Modules

Sun Java System Web Server 7.0 enables you to write customized classes for the various phases of the server lifecycle. For instance, a user may have a startup code that ensures that a remote data source is available for the applications. Such classes are notified of server lifecycle events supporting Java based tasks within the Web Server environment. These tasks automatically perform actions such as starting the server and sending notification if the server shuts down. You can use this support to instantiate singletons, RMI servers, and so forth. For more information, see List of Elements in Sun Java System Web Server 7.0 Update 2 Administrator’s Configuration File Reference

Session Replication

The intention of session replication is to provide sufficient session failover support through in-memory-backup of HTTP sessions to another server instance of the same cluster. This feature covers most usage scenarios. For more information, see Configuring Session Replication in Sun Java System Web Server 7.0 Update 2 Administrator’s Guide

API Changes from Web Server 6.1 to Web Server 7.0

Sun Java System Web Server has the following core components:

For more information about non-Java APIs and programming technologies, see the Sun Java System Web Server 7.0 Update 2 Developer’s Guide and the Sun Java System Web Server 7.0 Update 2 NSAPI Developer’s Guide.