This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I need a way to debug a java bean when used by a jsp. I tried running the bean with a stand alone main() method and everything works fine. However, when I call a jsp that references a method in the bean, I'm getting null objects returned. To debug the bean, I tried passing the jsp's ServletContext object to my bean and then calling the ServletContext.log method from within the bean. This does not produce any output in the webservers error log. This is a handy way to debug a jsp though. Finally, I tried creating a method in the bean that writes a message to a file. I can call this bean method from the jsp and it writes my message to the file. I then tried creating an instance of the bean within the another bean method that the jsp calls. In this other method that the jsp calls, I tried calling my method that writes to the file. Again, no output was produced. Hope this makes sense!
The System.out.println typically goes out to the window in which you started the server. If you started it as a background server and killed the window, then you won't be able to see the contents. Try restarting the IPlanet server in a new window and check its contents.
Joined: Sep 26, 2000
As usual, the error had to do with something else. I wasn't initializing the bean correctly from the jsp. Once this was corrected, both of my methods for logging started working. Consider this issue closed. Thanks