CS6320:  SW Engineering of Web Based Systems

 

   Debugging a Servlet
The Problem
  • Unlike Applications and Applets, can be more challenging to debug as they are run remotely on a server....so you do not have a console window to print errors to directly and watch the progress.  Also,  Applications and Applets that can be run locally and if you have a nice compiler you can set break-points,etc.  This is not true for Servlets.



Possibilities:
1) View the HTML source returned by the browser.  You may have missing tag that is causing the browser to choke.

2) Write messages to the log file.  The HttpServlet class has a method called log, you can uses this to write information to a log file.  

  • Location of  log file is server-specific, see documentaiton for your serverl.


3) Write messages to your own file on the server.

4) Return error page to client

  • return via generated web-page, any error messages.
  • Alternatively, use sendError() method of HttpServletResponse class (in your doXXX methods)
     
© Lynne Grewe