SAS® AppDev Studio 3.3 Developer's Site

Building Java Into the Content Portion of a Web Application Project

The Eclipse Web Tools Platform (WTP) currently assumes that all Java classes built within a Dynamic Web Project (and as a result, SAS Web Application Projects) are intended to be deployed under the Web application's WEB-INF/classes directory. Also, any JAR files to be deployed are assumed to belong in the WEB-INF/lib directory. If you are working with applets or Java Web Start applications, you might need to place Java classes and JAR files in the Web content portion of a Web application project.

Unfortunately, the WTP does not officially support placing classes and JAR files in a Web application project. This is because there is no user interface within the WTP that supports the creation of additional Web content folders in a Dynamic Web Project. Since it is not advisable to place built artifacts into the primary Web content folder of the project, you have to create new Web content folders and manually add them by editing the "component" file that is found in the .settings folder of the project. (The actual file name varies depending on which version of Web Tools Platform created the project.)

Creating new Java source folders with their own separate build folders enables you to have the needed project configuration. Follow these steps:

  1. In the Navigator view, select the Web Application Project you want to modify.
  2. Open the pop-up menu and select Properties.
  3. Switch to the Java Build Path page and select the Source tab.
  4. Click Add Folder and then click Create New Folder.
  5. Enter a folder name. Then for the
    1. Web Tools Platform 1.0.x and SAS AppDev Studio 3.2, click OK twice to return to the Java Build Path page.
    2. Web Tools Platform 1.5.x and SAS AppDev Studio 3.2.1, click Finish and then click OK.
  6. Select the Allow output folders for source folders check box, if it is not already selected.
  7. Expand the new Java source folder, select the Output Folder item, and then click Edit.
  8. Select the Specify output folder option and then click Browse.
  9. Select the project folder and click Create New Folder.
  10. Enter an output folder name and click OK four times to close the Properties dialog box.
  11. Switch to the Resource perspective, or open the Navigator view in your current perspective.
  12. Expand the .settings folder for the project and open the .component or org.eclipse.wst.common.component file, whichever one exists.
  13. Find the wb-resource element whose source-path attribute is set to the new Java source folder.
    1. Modify the source-path attribute to specify the new output folder.
    2. Modify the deploy-path attribute to be a forward slash or another suitable deployment location.
  14. Save the .component file or the org.eclipse.wst.common.component file.
  15. Move, copy, or create the Java classes with the package folders in the new Java source folder. If you are using the Package Explorer or the Project Explorer views, Move is a submenu item on the Refactor pop-up menu. In the Navigator view, Move available from the pop-up menu.

The Java classes placed in the new Java source folder will be included in the content portion of the Web application when it is published to a server or exported as a WAR file.