Debugging JSP files

You can detect and diagnose errors in your JSP files by debugging. You can set breakpoints, suspend threads, step through the code, and examine the contents of the variables.

To debug a JSP file:

  1. From the Source page, select Add Breakpoint from the pop-up menu in the line numbering area in the left margin where you want the breakpoint added.
  2. If you are debugging remotely, open the appropriate server in the Servers view of the Server Perspective (Window > Open Perspective > Server), and ensure that the Generate debug information when compiling JSPs (debug mode only) check box is selected. Close the server editor.
  3. Select the JSP file and select Run on Server from the pop-up menu.

    The server will be automatically started in debug mode. The debugger stops on the breakpoint when displaying the JSP

  4. Step through the JSP file, and examine and change any applicable variable values
Tip:
  1. If you do not plan to set and stop at breakpoints when running JSP files in the WebSphere® Test Environment, you can improve JSP performance by changing the Run on Server action, so that it starts the server in non-debug mode. (The default is debug mode.) You can change the Run on Server action behavior by selecting Window > Preferences > Server. Clear the Run on Server action starts the server in debug mode check box.
  2. When using WebSphere Application Server, you can save the generated .java files compiled from JSP files, by adding the following statements to the ibm-web-ext.xmi file in your Web application:
    <jspAttributes xmi:id="JSPAttribute_1" name="keepgenerated" value="true"/>
    <jspAttributes xmi:id="JSPAttribute_2" name="scratchdir" value="C:\temp"/>
    The generated files are stored in the location specified by the "scratchdir" property.
Related concepts
JavaServer Pages (JSP files)
Related tasks
Creating JSP files
Testing JSP files on a server
Editing JSP files
Adding an embedded file to a JSP page

Feedback