Create Web applications

Web applications are J2EE applications that can be deployed onto an application server. Web applications are projects comprised of one or more related servlets, JSP files, and HTML files that one can manage as a unit. Web applications are called WAR files because enterprise application projects are stored in WAR files.

 

Before you begin

This article assumes that you have created and unit tested Servlets, JSP files and other Web components that you want to assemble in an enterprise application and deploy onto an application server.

 

Overview

In the Application Server Toolkit (AST) and Rational Web Developer assembly tools, you create and maintain resources for Web applications in Web projects. There are two types of Web projects, dynamic and static. Dynamic web projects can contain dynamic J2EE resources such as servlets, JSP files, filters, and associated metadata, in addition to static resources such as images and HTML files. Static Web projects only contain static resources.

Dynamic Web projects are always embedded in enterprise application projects. Creating a Web project in an assembly tool requires that an enterprise application (EAR) project exist, or the assembly tool creates one for you. Creating a Web project updates the application.xml deployment descriptor of the specified enterprise application project to define the Web project as a module element. If you are importing a WAR file rather than creating a Web project anew, the WAR Import wizard requires that you specify a Web project, which already requires an EAR project.

This article describes how to create a dynamic Web project using an assembly tool. For instructions on how to create a static Web project, see the Application Server Toolkit or Rational Web Developer online help, or the Application Server Toolkit information center that accompanies this information center.

 

Procedure

  1. Start an assembly tool.

  2. If you have not done so already, configure the assembly tool for work on J2EE modules. Ensure that J2EE and Web capabilities are enabled.

  3. Click File > New > Project > Web > Dynamic Web Project > Next. Or, if you have created a Web project before, click File > New > Dynamic Web Project.

  4. On the Dynamic Web Project page:

    1. Specify a Web project (WAR file) name.

    2. Specify a location for the WAR file. To change the default WAR file location, click Browse and specify a new location.

    3. Click Show Advanced to display hidden settings.

    4. Specify whether you want a WAR file that supports 2.2, 2.3 or 2.4 servlet version. Select the appropriate Sun Microsystems Servlet and JSP specification level for the dynamic elements you plan to include in your Web project. Any new servlets and JSP files that you expect to create should adhere to the latest specification level available; previous specification levels are offered to accommodate any legacy dynamic elements that you expect to import into the project.

    5. Select a target server. Select the WAS v6.0 target server to use V6 WAS capabilities.

    6. If you want to add Web components to an enterprise application (EAR file), select Add module to an EAR project.

    7. If you selected Add module to an EAR project, customize the Web project:

      1. Specify a new or existing enterprise application (EAR) project to be associated with your new Web project for purposes of deployment. Note: If you want to add a Web project as a module to another enterprise application project in the future, open the application.xml editor for the enterprise application project and select Add on the General page.

      2. Provide a Context Root value. The context root is the Web application root, the top-level directory of your application when it is deployed to a Web server. The default value is the name of your Web project. Note: We can change the context root after you create a project using the project Properties dialog, which you access from the project context menu.

      3. Specify whether you want to add support for annotated Java classes to the Web application.

    8. Optional: If you are creating a new Web project or if you have no module dependencies to specify, skip this step. Otherwise, click Next to specify module and file dependencies.

  5. Click Finish.

 

Result

A new Web project is created, reflecting the J2EE folder structure that specifies the location of Web content files, class files, class paths, the deployment descriptor, and supporting metadata. Files for the Web project are shown in the Project Explorer view under Enterprise Applications and Dynamic Web Modules.

 

What to do next

We can now begin creating or importing content for your Web project using the New File wizards or the Import wizards available from the File menu or from the popup menu for the Web module. For example, right-click the Web module, click Import > WAR file and specify the WAR file to import.


 

See Also


Web applications
Web modules
Enterprise (J2EE) applications

 

Related Tasks


Assembling applications
Assembling Web applications

 

Related Information


Import WAR files