Friday, November 16, 2007

Steps to Create Web Application in JSP & Servlet

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.

WebApplicationName/

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.

/WEB-INF/web.xml

The Web Application deployment descriptor that configures the Web Application.

/WEB-INF/weblogic.xml

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.

/WEB-INF/classes

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

/WEB-INF/lib

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

No comments:

Post a Comment

Yahoo! News: Technology News