[ Team LiB ] |
Web Applications DefinedWeb applications were originally introduced in the Servlet 2.2 specification, and are currently defined as follows by the Servlet 2.3 specification: “A Web application is a collection of servlets, HTML pages, classes, and other resources that make up a complete application on a Web server.” In other terms, a Web application is usually the layer between the Web client and the business layer, and acts as a bridge between them by passing the user requests to the business components and the processed response to the Web client. A typical Web application consists of one or more of the following components:
Apart from the preceding components, a Web application contains configuration files containing the metadata that describes the application. The clients to Web-based applications are categorized as thin clients, as opposed to traditional application clients, which are characterized as fat clients. In a traditional application, such as a three-tier application framework, the client layer is responsible for user interaction as well as some of the application logic, which makes it fat. In a Web-based application, the client is driven from within a browser that manages the user interaction in a way similar to that of the fat clients, but the application logic is completely embedded in the server components that make up the Web applications defined earlier. The Web client user interface is usually defined using HTML, variations of it (for example, DHTML), or an XML/XSL combination. There are clearly defined protocols for data exchange between the client layer and the Web application, depending on the server components serving the client requests. But the most popular and widely used protocol is the HTTP/HTTPS protocol. HTTPS is a secure flavor of HTTP protocol for information exchange between Web applications (for example, servlets and JSP) and Web clients. Before we look at some of the key elements of the Web application, let's look at the environment in which Web applications run. Web ContainerThe J2EE platform provides the necessary infrastructure for servicing client requests. These client requests might come from traditional clients or from Web clients. An application server such as WebLogic Server, providing the J2EE infrastructure, has one or more of the specific runtime environments that form the core of the product. These runtime environments are responsible for providing the services necessary for the different J2EE components such as servlets and EJBs. These are called containers. The most important of them are the Web container for Web applications and the EJB container for Enterprise JavaBeans. Figure 6.1 gives an idea of what each of the runtime environments hosts and the type of client requests they handle. Figure 6.1. Anatomy of an application server.Let's look at the need for these containers and benefit they offer to the components running within their environment. One of the fundamental goals of the J2EE application server framework is to provide the basic operating environment for all applications running within it. In other words, a business application such as an airline reservation system should concentrate on providing the business functions necessary to run the business, such as reservation, cancellation, flight status, and so on. Such an application should not be worried about transaction and state management, resource pooling, and other services. These services are common to most business applications. The different containers that are bundled as part of the application server provide the operating environment. Now let's look at the basic services offered by the Web container that is the runtime environment for the Web applications. Web Container ServicesThe Web container is the interface between the J2EE components, such as servlets, and the low-level, platform-dependent functionality that's needed for the execution of the business function embedded in the component. There are certain rules of engagement for the container to provide the services to these components. The components are bundled into a well-defined package as specified by the J2EE specification and deployed into the Web container. The package contains application code as well as J2EE and vendor-specific configuration files that describe the application. The configuration parameters that are described using the XML-based configuration files specify certain container settings for every Web component and also specify settings for the Web application in totality. In short, these container settings help configure the basic support provided by the J2EE server as needed by the Web application. The support includes providing services such as security, transaction, JNDI lookup, and external resource mapping, to name a few. A host of configurable services makes the life of the application deployer much easier. In most cases, a Web application can be deployed to heterogeneous environments with changes only to the configuration. For example, a Web component might have relaxed security settings in the development environment, whereas this would have to change when it's rolled into a production environment. Alternatively, the requirements might include that the application allow for a certain level of access to database data in one production environment and another level of database access in another production environment. All these are possible without change in the underlying application code with the help of the configuration files and the basic services offered by the container. Let's look at the some of benefits that the WebLogic Server offers for the Web container:
Web Application ComponentsAs mentioned earlier in the chapter, the components that make up a Web application include servlets, JavaServer Pages, and their associated libraries and classes; specifically, the JSP tag library, JavaBeans, and so on. Let's look at each of these components in detail:
Web Application ConfigurationApart from one or more of the key components, a Web application contains configuration-related information in a set of XML files that describes the Web application. These configuration files contain entries that are used by the Web container to provide the configurable services needed by the application, such as security and so on.
The configuration elements of web.xml are governed by the DTD (http://java.sun.com/dtd/web-app_2_3.dtd) defined as part of the J2EE Servlet Specification (V 2.3). The elements defined in web.xml can be grouped into the following types:
NOTE Similar to web.xml, the configuration elements of weblogic.xml are controlled by the following DTD http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd. Some of the most important elements defined in weblogic.xml are
Figure 6.2 summarizes the discussion in this section and also touches on the deployment descriptors that make up the Web application. Figure 6.2. Web application and containers.In Figure 6.2, Web Application-1 and Web Application-2 represent two distinct applications that may be based on functionality, for example. In an airline reservation system, one Web application could cater to administrative functions executed by supervisors and another Web application could be related to customer-centric functions such as reservations, and so forth. As you can see from Figure 6.2, Web components are building blocks of all Web applications. The supporting cast for these applications includes other Java classes and static documents that can be in HTML and JPG file formats. |
[ Team LiB ] |