Debugging servlets

Debugging servlets is a special case of debugging classes loaded through a custom class loader. Servlets run in the Java™ runtime of an application server such as IBM® WebSphere® Application Server for IBM i or the IBM Integrated Web Application Server for i. You have several options to debug servlets.

You can debug servlets by following the instructions for classes loaded through a custom class loader.

You can also use the interactive display of your server to debug a servlet by completing the following steps:

  1. Use the javac -g command in the Qshell Interpreter to compile your servlet.
  2. Copy the source code (.java file) and compiled code (.class file) to a directory in your classpath.
  3. Start the server.
  4. Run the Start Service Job (STRSRVJOB) command on the job where the servlet runs.
  5. Enter STRDBG CLASS(myServlet), where myServlet is the name of your servlet. The source should be displayed.
  6. Set a breakpoint in the servlet and press F12.
  7. Run your servlet. When the servlet hits the breakpoint, you can continue debugging.

Another way to debug Java programs and servlets that run on your system is to use the IBM i Debugger. The IBM i Debugger provides a graphical user interface that enables you to more easily use the debugging capabilities of your system.