Chapter 3. Web Development

Create a web project

Creating new static Web projects

In the workbench, you create and maintain resources for Web applications in Web projects. If you want to create a static, content-based Web application that contains no dynamic files, such as JSP or servlets, use the Create a Web Project wizard to create a new Web static project, as follows:

  1. To launch the Web Project wizard in the Web perspective, select File > New > Web Project. Note: From other perspectives, launch the Web Project wizard by selecting File > New > Project. Then select the Web option, Web Project, and then the Next button.

  2. Provide a name and storage location for the Web project.

  3. Click the Static Web Project radio button.

  4. Optionally, select one or more of the Web Project features, such as the Create a default CSS file checkbox, which creates a default CSS file (called Master.css) for any HTML and JSP files included in the project.

    Static Web Project

  5. Click Next.

  6. Provide a Project document root value. A project document root is the default relative path to static Web content from the server root when a static Web project is published. For example, if the project document root is myProject, then the project will be published to http://server_root/myProject. It is used to create the URL that links to Web resources in a static Web project, so Web resources on a Web server can be grouped in folders that correspond to Web projects in the workbench.

    Project document root

  7. Click Finish, and the wizard will create an empty project container primed with the appropriate content folder structure.

  8. You can begin creating or importing content, using Web resource editors or the Import wizards:

    Ready Static Project

Creating new J2EE Web projects

In the workbench, you create and maintain resources for Web applications in Web projects. Use the Create a Web Project wizard to create a new J2EE Web project, as follows:

  1. To launch the Web Project wizard in the Web perspective, select File > New > Web Project. Note: From other perspectives, launch the Web Project wizard by selecting File > New > Project. Then select the Web option, Web Project, and then the Next button.

  2. Provide a name and storage location for the Web project.

  3. Click the J2EE Web Project radio button.

  4. Optionally, select one or more of the Web Project features, such as the Create a default CSS file checkbox, which creates a default CSS file (called Master.css) for any HTML and JSP files included in the project. You can also add custom tag libraries for various purposes. When you select a feature, a description is provided.

    Dynamic Web Project

  5. Click Next.

  6. Specify the name of a new or existing Enterprise Application project that the new Web project should be associated with for purposes of deployment. NOTE: If you want to add a Web project as a module to another Enterprise Application project in the future, you can open the application.xml editor for the Enterprise Application project and select the Add option in the General page.

  7. Specify a context root for the Web project. The context root is the Web application root, the top-level directory of your application when it is deployed to a Web server. You can change the context root after you create a project using the project Properties dialog, which you access from the project's context menu. The context root can also be used by the links builder to ensure that your links remain ready to publish as you move and rename files inside your project.

  8. From the J2EE Level drop-down list, select the appropriate Sun Microsystems Servlet and JSP specification level for the dynamic elements to be included in your Web project. It is recommended that 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 accomodate any legacy dynamic elements that you expect to import into the project. By default, the Web project's J2EE level is set to the Workbench's J2EE level. Project preferences are initialized when the project is created. If you want to update these preferences, select Window > Preferences > J2EE, and then choose the appropriate J2EE level from the J2EE property settings. If you choose to create a new Enterprise Application project for this Web project, the J2EE level setting controls the level of the resulting EAR file as well.

    Project Wizard

  9. Click Next if you wish to configure module dependency information, or if you need to supply additional information for any of the Web project features that you selected in the first page of the wizard. Otherwise, click Finish, the wizard will create an empty project container primed with the appropriate folder structure, along with a deployment descriptor file that describes the current project.

  10. In the Module Dependencies page, select and set dependent JAR files for modules within the associated Enterprise Application project. Specifying dependencies on this page updates the runtime classpath and Java project build path with the appropriate JAR files. Supply values for the following fields:

    • The Project name field displays the Web project name entered on the previous page of the wizard.

    • The Enterprise Application project name field displays the Enterprise Application project name entered on the previous page of the wizard.

    • Use the Available dependent JARs field to select JAR files that are required at runtime.

    The Manifest Class-Path displays the classpath for the selected JAR file(s).

    Module Dependencies

  11. Click the Next button if you need to supply additional information for any of the Web project features that you selected in the first page of the wizard. If you click Finish, the wizard will create an empty project container primed with the appropriate folder structure, along with a web.xml file that describes the current project.

  12. Click Finish

  13. The new project will reflect the J2EE folder structure that specifies the location of web content files, class files, classpaths, the deployment descriptor, and supporting metadata. You can begin creating or importing content, using Web resource editors or the Import wizards.

    Ready Dynamic Project

Professional hosting     Belorussian informational portal         Free SCWCD 1.4 Study Guide     Free SCBCD 1.3 Study Guide     Free SCDJWS 1.4 Study Guide     SCDJWS 1.4 Quiz     IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide     Free Mock Exam Engine