Skip to main content
Windward

Running the Java Servlet Example

engine-wiki-logo.pngOverview

This is a basic example on how to use the Windward Reports Java engine in a web application. This example is a pure servlet implementation (no JSPs or EJBs).

Basic Information

You are free to use this example in any way you wish. The instructions are for Windows systems, but the setup process is very similar for any other system that Tomcat supports.

There are two front-end sites for this example.

  • The first is static, where you are looking at information on a specific employee. There is a single button to generate a report for that individual.
  • The second one is more dynamic. You choose which leave request number you want the report to be on and the output format.

Video

Setup

  1. Install the Java SE JDK; Either the 32 or 64 bit version will work.
  2. Setup environment variable JAVA_HOME (point this to the root installation of your Java installation; for example "C:\Program Files\Java\jdk1.6.0_23")
    1. Right click My Computer
    2. Click Properties
    3. Click "Advanced system settings"
    4. Click "Environment Variables..."
    5. Under "System Variables", look for the JAVA_HOME variable.
      • If it is not there, click "New...", then type JAVA_HOME for Variable Name and the path of your jdk installation for Variable Value.
      • If it is there, click "Edit..." and ensure that it points to the path of your jdk installation.

Instructions

Installation of Tomcat

Note: all links assume you are running on localhost.

  1. Go to http://tomcat.apache.org/download-60.cgi.
  2. Click the link for the Zip File Download under Core. Do not download the windows installation, the code does not work.
  3. Save the file.
  4. Once the download is complete, open the folder that the file was saved to.
  5. Right click the file, highlight WinZip, and click “Extract to…”
  6. Navigate to the C: directory, and click unzip.
  7. In your C: directory, rename the folder “apache-tomcat-6.0.32” to “tomcat6”.
  8. Open a command prompt.
  9. Type cd\ to navigate to the root C: Directory
  10. Type cd tomcat6\bin to navigate to the tomcat6 bin folder.
  11. Type startup.bat to start Tomcat.
  12. In a web browser, navigate to http://localhost:8080. Now that tomcat is installed, you should see the tomcat website. If you do not see the tomcat website, tomcat did not correctly install.
  13. Return to the command prompt, and type shutdown.bat to shut down tomcat.

Running the Servlet Example

  1. Open the Java Engine’s Catapult Help Menu. (Start -> All Programs -> Windward Studios -> Windward Reports Java Engine -> Java Engine Help Launcher)
  2. Click the Servlet tab.
  3. Click the Example Source button.
  4. Copy the contents of the folder.
  5. Navigate to C:\tomcat6\webapps.
  6. Create a new folder named “JavaServletExample”.
  7. Open the folder, and paste. There should be four folders and seven files in the JavaServletExample folder (The path should be 'C:\tomcat6\webapps\JavaServletExample'):
    • 'files' folder
    • 'META-INF' folder
    • 'src' folder (contains the source code for this example)
    • 'WEB-INF' folder
    • 'index.html' file
    • 'ServletExample.iml' file (IntelliJ project file)
    • 'ServletExample.ipr' file (IntelliJ project file)
    • 'ServletExample.iws' file (IntelliJ project file)
  8. If you did not enter your license key during the install or you installed using the ZIP file, copy and paste your Java Engine key into the 'C:\tomcat6\webapps\JavaServletExample\WEB-INF\WindwardReports.properties' file.
    (The key already in the WindwardReports.properties file is not valid.)
  9. Open a command prompt and startup tomcat again by typing cd\ to go to the root directory, cd tomcat6\bin to go to the bin folder, then typing startup.bat.

Testing the Sample

  1. In a web browser, go to http://localhost:8080/JavaServletExample.
  2. Scroll down to the heading “Testing the sample” and click on the first example.
  3. Click “Create Letter" to run and open the report.
  4. Return to http://localhost:8080/JavaServletExample
  5. Scroll down to “Testing the sample” and click on the second example.
  6. Choose a name from the dropdown, and choose a report output.
     
  7. Click “Run Report” to run and open the report.

Notes

  • All of the source code calling the Windward Java Engine can be found at 'C:\tomcat6\webapps\ServletExample\src'.
  • To build from the source, either
    • Run build.bat in the 'c:\tomcat6\webapps\JavaServletExample\src\com\windwardreports' directory. NOTE: You will need to have javac.exe in your PATH or specify the full path location in build.bat.
    • Open the ServletExample.ipr in IntelliJ and build the project using the UI.
  • Was this article helpful?