Thursday, April 25, 2013

Deployment : Creating War file and directory structure

WAR Directory Structure    
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 directory 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.
********************************************************************************************************
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.
DefaultWebApp/
Place your static files, such as HTML files and JSP files in the directory that is the document root of your Web Application. In the default installation of WebLogic Server, this directory is calledDefaultWebApp, under user_domains/mydomain/applications.
DefaultWebApp/WEB-INF/web.xml
The Web Application deployment descriptor that configures the Web Application.
DefaultWebApp/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.
DefaultWebApp/WEB-INF/classes
Contains server-side classes such as HTTP servlets and utility classes.
DefaultWebApp/WEB-INF/lib
Contains JAR files used by the Web Application, including JSP tag libraries.
**********************************************************************************
Creating Web Applications: Main Steps
Here are the main steps for creating a Web application:
  1. Create the HTML pages and JavaServer Pages (JSPs) that make up the Web interface of the Web application. Typically, Web designers create these parts of a Web application.

  2. Write the Java code for the servlets and the JSP taglibs referenced in JSPs. Typically, Java programmers create these parts of a Web application.
  3. Compile the servlets into class files.
  4. Arrange the resources (servlets, JSPs, static files, and deployment descriptors) in the prescribed directory format. ( as above in red )
  5. Create the web.xml and weblogic.xml deployment descriptors.
    The web.xml file defines each servlet and JSP page and enumerates enterprise beans referenced in the Web application. The weblogic.xml file adds additional deployment information for WebLogic Server.
    Create the web.xml and weblogic.xml deployment descriptors manually or using WebLogic Builder. 

  6. Package the HTML pages, servlet class files, JSP files, web.xml file, and weblogic.xml file into a WAR file.
    Create a Web application staging directory and save the JSPs, HTML pages, and multimedia files referenced by the pages in the top level of the staging directory.
    Store compiled servlet classes, taglibs, and, if desired, servlets compiled from JSP pages are stored under a WEB-INF directory in the staging directory. When the Web application components are all in place in the staging directory, you create the WAR file with the JAR command.
  7. Auto-deploy the WAR file on WebLogic Server for testing purposes.
    While you are testing the Web application, you might need to edit the Web application deployment descriptors. You can do this manually or use WebLogic Builder.
  8. Deploy the WAR file on the WebLogic Server for production use or include it in an Enterprise ARchive (EAR) file to be deployed as part of an enterprise application.

No comments: