The debugger enables you to detect and
diagnose errors in your application. It allows you to control the execution
of your program by setting breakpoints, suspending threads, stepping through
the code, and examining the contents of the variables. You can debug a servlet
on a server without losing the state of your application.
To debug a servlet on a server:
- In the Project Explorer view, open your servlet. In a Web project, servlets are located in the JavaSource folder. The
servlet opens in an editor.
- To set one or more breakpoints in the editor,
double-click in the margin beside the line of code that you want to set as
a breakpoint.
- To add the project to the server, see the Adding projects to a server topic in the online help.
- Select the servlet and from the servlet's context
menu in the Project Explorer view, click Debug As > Debug on Server. Open the Servers view to see that the server is launched.
- When the breakpoint is hit, the Debug view
opens. Step through the code, inspect and display variables, and
make any necessary changes to the servlet. For detailed information on debugging,
refer to the online help.
- When you are finished debugging, remove the
breakpoint and save the servlet.
- Click the Resume icon
on the Debug toolbar to execute the servlet.
- If you have hot method replace enabled, your
changes are already in the running application.
- If you have automatic class reloading enabled,
which is the default setting, click the Refresh icon
in the Web Browser to update the changes. You do not lose the state
of your application.
- If you do not have automatic class reloading
enabled, you lose the state of the application. To
update the changes, restart the server.
- For WebSphere® Application
Server V5.11, you must restart the EAR project. Restart the project
by selecting the server in the Server view. Right-click the server, click Restart <project
name> .
- For Tomcat: Restart the server.
1 Not available in WebSphere Application Server Toolkit
V6.1.x, but available in products such as Rational
® Application Developer V7.0.x
or Rational Software
Architect V7.0.x