BEA Logo BEA WebLogic Server Release 6.1

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT



  WebLogic Server Doc Home   |     Web Applications   |   Previous Topic   |   Next Topic   |   Contents   |   Index   |   View as PDF

Web Applications Basics


The following sections describe how to configure and deploy Web Applications:


Overview of Web Applications

A Web Application contains an application's resources, such as servlets, JavaServer Pages (JSP), JSP tag libraries, and static resources such as HTML pages and image files. A Web Application can also define links to resources outside of the application such as Enterprise JavaBeans (EJBs). Web Applications deployed on WebLogic Server use a standard J2EE deployment descriptor in conjunction with an optional WebLogic-specific deployment descriptor to define the resources and their operating parameters.

JSP pages and HTTP servlets can access all services and APIs available in WebLogic Server. These services include EJBs, database connections through Java Database Connectivity (JDBC), JavaMessaging Service (JMS), XML, and more.

Web Applications use a standard directory structure defined in the J2EE specification and can be deployed as a collection of files that use this directory structure (this type of deployment is called exploded directory format) or as an archived file called a .war file. Deploying a Web Application in exploded directory format is recommended primarily for use while developing your application. Deploying a Web Application as a .war file is recommended primarily for production environments.

The WAR file can be deployed alone or packaged in an Enterprise Archive (EAR file) with other application components. If deployed alone, the archive must end with a .war extension. If deployed in an EAR file, the archive must end with an .ear extension. (Note: If you are deploying an entire directory, do not name the directory .ear, .war, .jar and so on.)


Main Steps to Create a Web Application

The following steps summarize the procedure for creating a Web Application. You may want to use some of the provided developer tools for creating and configuring Web Applications. For more information, see Web Application Developer Tools.

To create a Web Application:

  1. Arrange the resources (servlets, JSPs, static files, and deployment descriptors) in the prescribed directory format. For more information, see Directory Structure.

  2. Write the Web Application deployment descriptor (web.xml). In this step you register servlets, define servlet initialization parameters, register JSP tag libraries, define security constraints, and define other Web Application parameters. (Information on the various components of Web Applications is included throughout this document.) Place the descriptor in the WEB-INF directory of the Web Application.

    For detailed instructions, see Writing the web.xml Deployment Descriptor.

    You can also use the Administration Console to edit Web Application deployment descriptors. For more information, see Web Application Deployment Descriptor Editor Help.

  3. Create the WebLogic-specific deployment descriptor (weblogic.xml). In this step you define JSP properties, JNDI mappings, security role mappings, and HTTP session parameters. If you do not need to define any attributes in this file, you do not need to create the file.

    For detailed instructions on creating the WebLogic-specific deployment descriptor, see Writing the WebLogic-Specific Deployment Descriptor (weblogic.xml).

    You can also use the Administration Console to edit Web Application deployment descriptors. For more information, see Web Application Deployment Descriptor Editor Help.

  4. Archive the files in the above directory structure into war file. Only use archiving when the Web Application is ready for deployment in a production environment. (During development you may find it more convenient to update individual components of your Web Application by developing your application in exploded directory format.) To create a .war archive, use this command line from the root directory containing your Web Application:
    jar cv0f myWebApp.war .

    This command creates a Web Application archive file called myWebApp.war.

  5. (Optional). Archive the Web Application into an Enterprise Application.

  6. Deploy the Web Application on Weblogic Server. This final step configures your Web Application to service requests on WebLogic Server. For detailed instructions, see Deploying Web Applications.


Directory Structure

You develop your Web Application within a specified directory structure so that it can be archived and deployed on WebLogic Server, or another J2EE compliant server. All servlets, classes, static files, and other resources belonging to a Web Application are organized under a directory hierarchy. The root of this hierarchy defines the document root of your Web Application. All files under this root directory can be served to the client, except for files under the special directory WEB-INF, located under the root directory. The name of your Web Application is used to resolve requests for components of the Web Application.

Place private files in the WEB-INF directory, under the root directory. All files under WEB-INF are private, and are not served to a client.


Place your static files, such as HTML files and JSP files in this directory (or a subdirectory). This directory is the document root of your Web Application.


The Web Application deployment descriptor that configures the Web Application.


The WebLogic-specific deployment descriptor file that defines how named resources in the web.xml file are mapped to resources residing elsewhere in WebLogic Server. This file is also used to define JSP and HTTP session attributes.


Contains server-side classes such as HTTP servlets and utility classes.


Contains .jar files used by the Web Application, including JSP tag libraries.


URLs and Web Applications

You construct the URL used to access a Web Application from a client by using the following pattern:




is either a host name that is mapped to a virtual host or hostname:portNumber.


is the name of your Web Application.


is a servlet that is mapped to the servletPath.


is the remaining portion of the URL, typically a file name.

If you are using virtual hosting, you can substitute the virtual host name for the hoststring portion of the URL.

For additional information, see How WebLogic Server Resolves HTTP Requests.


Web Application Developer Tools

BEA provides several tools you can use to help you create and configure Web Applications. These tools are described in this section.

ANT Tasks to Create Skeleton Deployment Descriptors

You can use the WebLogic ANT utilities to create skeleton deployment descriptors. These utilities are Java classes shipped with your WebLogic Server distribution. The ANT task looks at a directory containing a Web Application and creates deployment descriptors based on the files it finds in the Web Application. Because the ANT utility does not have information about all of the desired configurations and mappings for your Web Application, the skeleton deployment descriptors the utility creates are incomplete. After the utility creates the skeleton deployment descriptors, you can use a text editor, an XML editor, or the Administration Console to edit the deployment descriptors and complete the configuration of your Web Application.

For more information on using ANT utilities to create deployment descriptors, see Packaging Web Applications.

Web Application Deployment Descriptor Editor

The WebLogic Server Administration Console has an integrated deployment descriptor editor. You must create at least a skeleton web.xml deployment descriptor before using this integrated editor.

For more information, see Web Application Deployment Descriptor Editor Help.

XML Editor

BEA now provides a simple, user-friendly tool from Ensemble for creating and editing XML files. It can validate XML code according to a specified DTD or XML Schema. The XML editor can be used on Windows or Solaris machines and is downloadable from BEA dev2dev.


back to top previous page next page