29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14.3 Stepping through code using the Online Catalog<br />

sample<br />

When stepping through code using the debugger, the application will stop when<br />

each Web object is loaded by the server; this is also referred to as the<br />

step-by-step mode. At this point, you can step into or over each statement in the<br />

code, inspecting variables and using other debugging features.<br />

Studio Site Developer has extensive help information on this topic, including<br />

debugging Java, JavaScript, stored procedures, and compiled language<br />

applications. This section will take you through a common debug scenario and<br />

point out the highlights of the debugger.<br />

Let’s assume for this sample that we want to verify that the xslFile variable of the<br />

FeaturedItemXMLServlet servlet is being set to the correct value. To do this, we<br />

are going to set a breakpoint in the servlet, run the application in debug mode,<br />

and then check the variable value using the Variables view.<br />

14.3.1 Setting breakpoints<br />

1. Open the Web perspective.<br />

1. Navigate to the featured_item package in the JavaSource folder and expand<br />

it.<br />

2. Open the FeaturedItemXMLServlet.java in the Java editor by double-clicking<br />

it.<br />

3. Place your cursor in the left editor marker bar on the line String html =<br />

genHTML(baosXML.toString(),xslContent);. Use the Edit -><br />

Find/Replace option to find the string if you don’t see it right away.<br />

4. Double-click to set a breakpoint. A marker will be shown at the line.<br />

Chapter 14. Testing and debugging 507

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!