FAQ
History |
Previous Home Next |
Search
Feedback |
DividerWeb 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:
- Server-side utility classes (database beans, shopping carts, and so on). Often these classes conform to the JavaBeans component architecture.
- Client-side classes (applets and utility classes)
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:
web.xml -
The Web application deployment descriptor- Tag library descriptor files (see Tag Library Descriptors)
classes
- A directory that contains server-side classes: servlets, utility classes, and JavaBeans componentslib
- A directory that contains JAR archives of libraries called by server-side classesYou 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:
- Select FileRight ArrowNew. This opens the new wizard.
- Scroll to the JSP & Servlet node and expand it.
- Select Web module.
- Click Next.
- Type the path to the directory for the Web module.
- 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 theweb.xml
file, you can view the deployment properties associated with the Web module.To view the Hello1 Web module:
- In the IDE, mount the filesystem
<
INSTALL
>/j2eetutorial/examples/web/hello1
.- Expand the nodes
hello1
Right 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:
- Mount the Web module as a filesystem.
- Expand the module and
WEB-INF
nodes.- To create a JSP page, right-click the module node and choose NewRight ArrowJSP & ServletRight ArrowJSP or Servlet.
- To create a servlet, right-click the
classes
node and choose NewRight ArrowJSP & ServletRight ArrowServlet.- Type a name for the JSP page or servlet.
- Click Finish.
FAQ
History |
Previous Home Next |
Search
Feedback |
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.