Debugging Windows

 <  Day Day Up  >  

Debugging Windows

Debugging is all about observing proper functioning of code and output of expected results. However, to do this, you need the details to be displayed in an orderly fashion.

WebLogic Workshop addresses this need by providing several debug windows that display meaningful information. Choose View, Debug Windows from the Workshop menu to view these windows, which are described in the following sections.

Locals Window

Every application uses variables, and one of the initial steps in debugging is checking the values in these variables. The Locals window automatically shows variables in scope. If the variables are of a primitive type, their values can be changed during debugging. If the variables are an instance of a class, you can expand them to view the members .

Multiple views are available for some types of variables. For example, a variable of type int can be viewed and edited as a decimal or hexadecimal integer. Another example is a variable of type java.lang.StringBuffer , which can be viewed in two ways:

  • Showing the contents as a string, including its length and capacity, as shown in Figure 5.5

    Figure 5.5. A variable of type java.lang.StringBuffer viewed as a string.

    graphics/05fig05.jpg

  • Showing the internal data structure, as shown in Figure 5.6

    Figure 5.6. The internal data structure for the variable type java.lang.StringBuffer .

    graphics/05fig06.jpg

To switch views, right-click on the variable name or the value, choose View As, and select the type of view.

Watch Window

Enter a variable name in the Watch window to observe changes in its values.

Streams Window

When working with JSP pages, a key area is checking the output stream that's generated ”that is, sent as a response to the browser. The Streams window is used to perform the same task.

Callstack Window

The Callstack window displays all the methods , in reverse chronological order, that were called to reach the current point. To view details on the variables in the method, simply click on the method name.

Threads Window

Currently running threads are shown in the Threads window. You can navigate to a particular method by clicking on the stack frame.

Breakpoints Window

The Breakpoints window lists all breakpoints that are set in the application. You can specify certain conditions for each breakpoint, if needed. To enable or disable a breakpoint, select the corresponding check box.

To understand how to use the integrated Debugger, consider the hypothetical Wonderland Casino application. Listing 4.2 in Chapter 4, "Developing with Page Flow," illustrates branching from within an action. This listing also has a method ( purchaseChips ) and two variables: amount and amt .

Assume that the result for highRoller is always confirmed; this means there's some problem with the values assigned to the variable. The amount variable is extracted from the request object.

To debug this problem, you would set a line breakpoint on the code that assigns values to the variables (the first two lines in the purchaseChips method). This enables you to check whether the value extracted from the request object is the expected value through the Locals or Watch window. Now refer back to Listing 4.3, which has four methods. Assume that the value in the confirmationNumber variable isn't what you expected. This listing uses two methods to determine this information: setconfirmationNumber and getConfirmationNumber . Therefore, you can use a method breakpoint to debug this problem. Depending on where the error is found, you can use the Step Into or Step Over command for this debugging exercise.

 <  Day Day Up  >  


BEA WebLogic Workshop 8.1 Kick Start
BEA WebLogic Workshop 8.1 Kick Start: Simplifying Java Web Applications and J2EE
ISBN: 0672326221
EAN: 2147483647
Year: 2004
Pages: 138

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net