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).
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.
- Windward Java Engine
- IntelliJ IDEA v11
- JDK 1.4 or newer
- Install the Java SE JDK; Either the 32 or 64 bit version will work.
- 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")
- Right click My Computer
- Click Properties
- Click "Advanced system settings"
- Click "Environment Variables..."
- 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.
Installation of Tomcat
Note: all links assume you are running on localhost.
- Go to http://tomcat.apache.org/download-60.cgi.
- Click the link for the Zip File Download under Core. Do not download the windows installation, the code does not work.
- Save the file.
- Once the download is complete, open the folder that the file was saved to.
- Right click the file, highlight WinZip, and click “Extract to…”
- Navigate to the C: directory, and click unzip.
- In your C: directory, rename the folder “apache-tomcat-6.0.32” to “tomcat6”.
- Open a command prompt.
- Type cd\ to navigate to the root C: Directory
- Type cd tomcat6\bin to navigate to the tomcat6 bin folder.
- Type startup.bat to start Tomcat.
- 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.
- Return to the command prompt, and type shutdown.bat to shut down tomcat.
Running the Servlet Example
- Open the Java Engine’s Catapult Help Menu. (Start -> All Programs -> Windward Studios -> Windward Reports Java Engine -> Java Engine Help Launcher)
- Click the Servlet tab.
- Click the Example Source button.
- Copy the contents of the folder.
- Navigate to C:\tomcat6\webapps.
- Create a new folder named “JavaServletExample”.
- 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)
- 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.)
- 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
- In a web browser, go to http://localhost:8080/JavaServletExample.
- Scroll down to the heading “Testing the sample” and click on the first example.
- Click “Create Letter" to run and open the report.
- Return to http://localhost:8080/JavaServletExample
- Scroll down to “Testing the sample” and click on the second example.
- Choose a name from the dropdown, and choose a report output.
- Click “Run Report” to run and open the report.
- 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.