Viewing the source code of the Ajax: Hello! Sample application

The source code of the Ajax: Hello! Sample application is provided within the AjaxHello.war Web module of the AjaxHello.ear file. There are two approaches to viewing the source code: through an Eclipse-based Integrated Development Environment (IDE) or by decompressing the AjaxHello.ear file, then decompressing the AjaxHello.war file contained inside.

Locating the Application Enterprise Archive (EAR)

The first step in viewing the source code is locating the AjaxHello.ear file. Depending on how you obtained and are viewing the documentation, there are two places the file can be located.

Viewing the Source Code in an Eclipse-based IDE

An Eclipse-based IDE is the simplest approach to examining the source code of the ear file. Use any Eclipse 3.2.X, 3.3.X with the Web Tools Project 2.5 or higher, or Rational Application Developer, version 7.0 or higher, can import the enterprise application archive (EAR) file when you complete the following steps: outlined below.

  1. From the Eclipse IDE menu, select File->Import.
  2. In the presented panel, expand the JavaTM EE option, then select EAR file, then click Next.
  3. In the EAR File entry field, click Browse, and select the file you located earlier. This action populates the other two fields.
  4. Accept defaults for the project name, if they are acceptable, and click Next.
  5. Click Finish.

When the import process completes, two new projects exist in the Eclipse Project Explorer: AjaxHello and AjaxHello_WEB. The application source code can be accessed from the AjaxHello_WEB project. To access the client or server code, refer to the following table for source code locations in the AjaxHello_WEB Eclipse project tree.

Client side (Web Browser code)
WebContent/indexDevelopment.html: Contains the Dojo Widget definitions and script connection functions. This file loads the unoptimized dojo profile.

WebContent/indexOptimized.html: Contains the Dojo Widget definitions and script connection functions. This file loads the optimized dojo profile.

WebContent/data/planets_filtered.json: Contains the data used to populate the dijit.form.Combobox widget.
Server side (servlet code)
Java Resources: src/Web App Libraries/AjaxHelloServices.jar/com.ibm.websphere.samples.ajaxhello/Greeter.class: Double-clicking this class will load the source code.

Java Resources: src/Web App Libraries/AjaxHelloServices.jar/com.ibm.websphere.samples.ajaxhello/CompressionServlet.class: Double-clicking this class will load the source code.

Viewing the source code by decompressing the enterprise application archives file

Enterprise application archives are file archives compressed using the ZIP algorithm. Therefore, the archive file can be expanded by any number of ZIP tools, including the Java archive (JAR) program. The following steps are written the user chooses to use their favorite ZIP tool.

  1. Expand the AjaxHello.ear file you located earlier into a directory on your system using your favorite compresses file tool.
    The following steps assumes EXPAND_DIR/AjaxHello is the correct location.
  2. List the files in the directory that AjaxHello.ear file was expanded into, EXPAND_DIR/AjaxHello.
  3. Locate EXPAND_DIR/AjaxHello/AjaxHello.war file in the list.
  4. Expand EXPAND_DIR/AjaxHello/AjaxHello.war file into a directory on your system.
      The following steps assumes that EXPAND_DIR/AjaxHello/AjaxHelloWAR file is the target directory.
  5. Expand EXPAND_DIR/AjaxHello/AjaxHelloWAR/WEB-INF/AjaxHelloServices.jar file into a directory on your system.
      The following steps assumes that EXPAND_DIR/AjaxHello/AjaxHelloWAR/AjaxHelloServices is the target directory.

After you have expanded the EAR file and WAR file contents, you can access the source code. To access the client or server code, refer to the following table for source code locations in the EXPAND_DIR/AjaxHello/AjaxHelloWAR directory.

Client side (Web Browser code)
indexDevelopment.html: Contains the Dojo Widget definitions and script connection functions. This file loads the unoptimized dojo profile.

indexOptimized.html: Contains the Dojo Widget definitions and script connection functions. This file loads the optimized dojo profile.

data/planets_filtered.json: Contains the data used to populate the dijit.form.Combobox widget.
Server side (servlet) code
AjaxHelloServices/com/ibm/websphere/samples/ajaxhello/Greeter.java

AjaxHelloServices/com/ibm/websphere/samples/ajaxhello/CompressionServlet.java