Saturday, November 22, 2008

Display a Java Program on The Web Browser

For the past week, I tried to upgrade the stack-johnson project. My basic goal was add wicket to the system so that anybody can run the program on the web browser with their own session. The stack project has very simple functionality and it was simple and nice enough to start with Wicket. My screen shot of the project is below.

Preparing for the Wicket
For using Wicket with your Java Project, I needed to download few tools below.

Jetty 6.1.9
Wicket 1.3.5
Slf4J 1.5.0

Problems Encountered During The Development
Setting environmental variables and classpath for this project was also as difficult as other project. I spent pretty much time to make sure program runs both on command window and eclipse environment. Also adding session to the project so that many users can using the stack project with their own session was challenge to me. I also had a small problem when I tried to display lastly pooped item on the screen. It was impossible to make a local variable and save popped item into that, because the java file renewed when any button clicked. So, I created a variable in the application java file and saved and retrieved the item from the application . By doing this, I clearly understood the why we need to have a application file when we using Wicket. The biggest challenging part was fix bugs from PMD. When I tried to verify the system, the PMD reported error for Jetty.java below:

All methods are static. Consider using Singleton instead. Alternatively,
you could add a private constructor or make the class abstract to
silence this warning.
I could not remove this warning for a while, and I finally added a method like below:

public void doNothing() {

System.out.println("Should not use this method");

}

Conclusion
Wicket is very useful tool when we need to run the application using Java and display the output of the program on the Web browser. I believe this was really good project to be done before doing duedates projects with Wicket.

Download Link
www2.hawaii.edu/~jeho/ICS413/stack-johnson-5.0.1124.zip

No comments: