This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes debugging a javabean called by jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "debugging a javabean called by jsp" Watch "debugging a javabean called by jsp" New topic

debugging a javabean called by jsp

mike mckenna

Joined: Sep 26, 2000
Posts: 6
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!
Ted Dong

Joined: May 16, 2001
Posts: 15
Have you tried just putting in some System.out.println() in your bean?
mike mckenna

Joined: Sep 26, 2000
Posts: 6
System.out.println was the first thing I tried. I can't figure out where the output is going from the webserver. I'm running IPlanet (can't tell what version) on an NT server. Thanks
parind poi

Joined: Jun 19, 2001
Posts: 9
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.
mike mckenna

Joined: Sep 26, 2000
Posts: 6
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
It is sorta covered in the JavaRanch Style Guide.
subject: debugging a javabean called by jsp
Similar Threads
JEE6 @Asynchronous annotation and threading question
deploying servlet in WAS 4.0
Emulating JSP 'usebean' command in a Servlet
[Struts] bean:define... - complex objects
Webspere 345 exam questions