FAQ
History
PreviousHomeNext Search
Feedback
Divider

Web Modules

Web components and static Web content files such as images are called Web resources. A Web module is the smallest deployable and usable unit of Web resources in a J2EE application. A J2EE Web module corresponds to a Web application as defined in the Java Servlet Specification.

Web modules are typically packaged and deployed as Web archive (WAR) files. The format of a WAR file is identical to that of a JAR file. However, the contents and use of WAR files differ from JAR files, so WAR file names use a .war extension.

In addition to Web components and Web resources, a Web module can contain other files including:

The top-level directory of a Web module is the document root of the application. The document root is where JSP pages, client-side classes and archives, and static Web resources are stored.

The document root contains a subdirectory called WEB-INF, which contains the following files and directories:

You can also create application-specific subdirectories (that is, package directories) in either the document root or the WEB-INF/classes directory.

Creating a Web Module

When you develop Web applications using the IDE, it creates the necessary Web module structure for you. It also creates or modifies the Web application deployment descriptor based on information entered into wizards and property sheets.

To create a Web module in the IDE:

  1. Select FileRight ArrowNew. This opens the new wizard.
  2. Scroll to the JSP & Servlet node and expand it.
  3. Select Web module.
  4. Click Next.
  5. Type the path to the directory for the Web module.
  6. Click Finish.

The Web module will be mounted as a filesystem in the IDE. Expand the filesystem and the WEB-INF node to view the Web module structure. If you click on the web.xml file, you can view the deployment properties associated with the Web module.

To view the Hello1 Web module:

  1. In the IDE, mount the filesystem
    <INSTALL>/j2eetutorial/examples/web/hello1.
  2. Expand the nodes hello1Right ArrowWEB-INF.

Creating a Web Component

You create a Web component in the context of a Web module. To create a Web component in the IDE:

  1. Mount the Web module as a filesystem.
  2. Expand the module and WEB-INF nodes.
  3. To create a JSP page, right-click the module node and choose NewRight ArrowJSP & ServletRight ArrowJSP or Servlet.
  4. To create a servlet, right-click the classes node and choose NewRight ArrowJSP & ServletRight ArrowServlet.
  5. Type a name for the JSP page or servlet.
  6. Click Finish.
Divider
FAQ
History
PreviousHomeNext Search
Feedback
Divider

All of the material in The J2EE Tutorial for the Sun ONE Platform is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.