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
- Start an assembly tool.
- If you have not done so already, configure the assembly tool for work on J2EE modules. Ensure that J2EE and Web capabilities are enabled.
- Click File > New > Project > Web > Dynamic Web Project > Next. Or, if you have created a Web project before, click File > New > Dynamic Web Project.
- On the Dynamic Web Project page:
- Specify a Web project (WAR file) name.
- Specify a location for the WAR file. To change the default WAR file location, click Browse and specify a new location.
- Click Show Advanced to display hidden settings.
- 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.
- Select a target server. Select the WAS v6.0 target server to use V6 WAS capabilities.
- If you want to add Web components to an enterprise application (EAR file), select Add module to an EAR project.
- If you selected Add module to an EAR project, customize the Web project:
- 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.
- 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.
- Specify whether you want to add support for annotated Java classes to the Web application.
- 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.
- 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