This script opens a new, small, floating window and puts TOC<name>.html and IX<name>.html files in it and sets a generic popup window code to enable the display of some viewlets in the WebLogic Platform Tour.
Previous Next

 Building the MedRec Applications

Tutorial 8: Walkthrough of Web Application Deployment Descriptors

This tutorial examines the deployment descriptor files that define the resources and operating attributes of the MedRec Web applications.

Like most WebLogic Server Web Applications, each MedRec Web application uses two deployment descriptor files, web.xml and weblogic.xml. These files reside in the WEB-INF folders that are part of the directory structure of WebLogic Server Web Applications.

A web.xml deployment descriptor file is a J2EE standard XML document that sets properties for a Web Application. These properties are defined by the DTD referenced in a heading in each web.xml file, at http://java.sun.com/dtd/web-app_2_3.dtd.

A weblogic.xml deployment descriptor file is an XML document that defines WebLogic Server-specific properties for Web applications. These properties are defined by the DTD at http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd.

The tutorial includes the following sections:

 

 

 

Prerequisites

Before starting this tutorial:

 

 

 

Procedure

The following procedure walks you through the contents of the web.xml and weblogic.xml files.

Step 1: Examine a web.xml file.

In this section, examine how the web.xml file from mainWebApp configures mainWebApp's resources. mainWebApp responds to HTTP requests in MedRec, either creating HTTP responses or forwarding requests to other Web components.

web.xml can define following attributes for a Web Application:

  1. In a text editor, open the web.xml file that configures mainWebApp, located at C:\medrec_tutorial\src\medrecEar\mainWebApp\WEB-INF.

  2. Note the required elements in the heading of the file, which set the encoding and point to the DTD that defines the elements and attributes that can be set in a web.xml file:

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <!DOCTYPE web-app

    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

    "http://java.sun.com/dtd/web-app_2_3.dtd">

    Use caution with this section of the file, as erroneous edits here will likely prevent the application from being deployed until they are corrected.

  3. The elements described in the following steps reside within the web-app element that they modify.

    <web-app>

    ....

    </web-app>

  4. Note the registration of servlets in web.xml. The servlet element and its servlet-class attributes set the name of the servlet and the location of the compiled class that executes the servlet.

    The following listing names a servlet called "action," and associates it with a class:

    <servlet>
    
      <servlet-name>action</servlet-name>
    
        <servlet-class>org.apache.struts.action.ActionServlet</servle
    t-class>
    

  5. The init-param attribute is part of the servlet element; in this case, of the servlet defined in the previous step. The servlet reads its init-param values when it is invoked.

           <init-param>

               <param-name>config</param-name>

               <param-value>/WEB-INF/struts-config.xml</param-value>

           </init-param>

  6. The servlet-mapping element determines how the MedRec application invokes a servlet.

    <servlet-mapping>

    <servlet-name>action</servlet-name>

    <url-pattern>*.do</url-pattern>

    </servlet-mapping>

  7. The welcome-file-list element defines the Web application's welcome files.

    <welcome-file-list>

    <welcome-file>index.jsp</welcome-file>

    </welcome-file-list>

  8. taglib defines the tag libraries that are available to the application:

       <taglib>

           <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>

           <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>

       </taglib>

See web.xml Deployment Descriptor Elements in Developing Web Applications for WebLogic Server.

Step 2: Examine a weblogic.xml File

In this section, examine the contents of the weblogic.xml file that configures the physicianWebApp. Physicians and nurses log in to the physician Web Application to search and access patient profiles, create and review patient medical records, and prescribe medicine to patients.

A WebLogic Server Web Application's weblogic.xml file can set, among other things, the following major properties:

  1. In a text editor, open the weblogic.xml file that configures physicianWebApp, located at C:\medrec_tutorial\src\physicianEar\physicianWebApp\WEB-INF.

  2. Note the heading that references the DTD file:
    <!DOCTYPE weblogic-web-app
    
     PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN"
    
    "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd"
    >
    

    This URL is the location of the current WebLogic Server 8.1 DTD for Web Applications.

  3. The elements and attributes in the weblogic.xml file are members of the weblogic-web-app element that opens and closes every instance of weblogic.xml:
    <weblogic-web-app>
    
    ....
    
    </weblogic-web-app>
    

  4. The session-descriptor element contains session parameters for the Web Application's servlet sessions. The parameter names refer to parameters specified in weblogic810-web-jar.dtd, whose values can be set within the same session-descriptor element.

    For example, the InvalidationIntervalSecs parameter is a performance-related setting that specifies the number of seconds the server waits before checking to determine if a session is invalid or has timed out.

    The next parameter, TimeoutSecs, sets the number of seconds the server waits before timing out a session.

    The value assigned to the third parameter, PersistentStoreType, determines the persistent store method for servlet sessions. The current value, replicated_if_clustered, means that sessions on this server are stored in accordance with the value set for the cluster of servers to which this server belongs—if the Web Application is deployed to a cluster. Absent a clustered server configuration, servlet sessions default to the memory PersistentStoreType, in which sessions are not stored persistently.

    <session-descriptor>
    
        <session-param>
    
          <param-name>InvalidationIntervalSecs</param-name>
    
          <param-value>60</param-value>
    
        </session-param>
    
        <session-param>
    
          <param-name>TimeoutSecs</param-name>
    
          <param-value>600</param-value>
    
        </session-param>
    
        <session-param>
    
          <param-name>PersistentStoreType</param-name>
    
          <param-value>replicated_if_clustered</param-value>
    
        </session-param>    
    
    </session-descriptor>
    

  5. The virtual-directory-mapping element sets the location that the servlet checks first when fulfilling HTTP image requests. Its paired elements, local-path and url-pattern, map the URL pattern of an incoming request to a physical location.
    <virtual-directory-mapping>
    
    <local-path>C:/bea/weblogic81/samples/server/medrec/src/comm
    on/web</local-path>
    
    <url-pattern>images/*</url-pattern>
    
    </virtual-directory-mapping>
    

  6. The context-root element in a weblogic.xml file sets the context root directory for a Web Application. The context root is the base path of a Web application relative to the server's base URL. For example, MedRecServer's base URL is http://localhost:7101 and the Web application's context root is physician. Users access components of the physician Web application relative to http://localhost:7101/physician.

    The setting physician means that users access the physicianWebApp when they specifically request it.

    <context-root>physician</context-root>
    

See weblogic.xml Deployment Descriptor Elements in Developing Web Applications for WebLogic Server.

 

 

 

Best Practices

 

 

 

The Big Picture

The MedRec application contains five Web Applications:

The resources and attributes of these Web Applications are defined by deployment descriptor files. This tutorial describes the function of these deployment descriptors, specifically web.xml, the standard J2EE Web application deployment descriptor file, and weblogic.xml, the WebLogic Server-specific Web application deployment descriptor file.

Deployment descriptor files configure properties for MedRec's applications and EJBs, as well as its Web applications.

For example, physicianEar, the application to which physicianWebApp belongs, also contains a session EJB component, physSessionEJBs. physSessionEJBs's deployment descriptor files, located at C:\medrec_tutorial\build\physicianEar\physSessionEjbs\META-INF, are the standard J2EE EJB deployment descriptor file ejb-jar.xml, and the WebLogic Server-specific EJB deployment descriptor file, weblogic-ejb-jar.xml.

medrecEar, the main MedRec application, is configured by a standard J2EE application deployment descriptor file, application.xml, located at C:\medrec_tutorial\src\medrecEar\META-INF.

You are encouraged to examine the EJB and application deployment descriptor files and the DTD files that they reference.

 

 

 

Related Reading

 

 Back to Top Previous Next