SlideShare ist ein Scribd-Unternehmen logo
1 von 24
V4.1
                                                                                                   Instructor Exercises Guide



EXempty   Exercise 8. Debug a Web Application

          Estimated time
                                  00:45


          What this exercise is about
                                  In this exercise, you debug the Web application running in the
                                  integrated test environment. IBM Rational Application Developer (V7
                                  and later) includes an integrated testing and debugging environment
                                  that can be used to debug J2EE applications.


          What you should be able to do
                                  At the end of the exercise, you will be able to:
                                   • Set up the Test Environment for debugging
                                   • Debug the application in Rational Application Developer


          Introduction
                                  The J2EE application that is debugged in this exercise is the library
                                  book renewal application. It is composed of a Web application with an
                                  associated Java utility module. Before the application can be
                                  debugged, the server needs to be started in debug mode.


          Requirements
                                  This exercise requires that the library Web project be implemented
                                  (Labs 1-4) and the library database installed (Lab 1).
                                  If the earlier labs were not completed, import the
                                  <LAB_FILES>DatabasesolutionDatabaseSolution.zip file.
                                  The library database needs to be re-installed, but this will be done as
                                  part of this exercise.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application         8-1
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide



Instructor exercise overview
In this exercise students will discover an error into the library enterprise application, and will
use the debugging features of IBM Rational Application Developer to find the source of the
error.


Students discover that renewals are being processed even if no renewal period was
requested. This is caused by the renewRequested variable keeping a value of true once it
has been set. The solution is to add a line of code to reset the variable to false as soon as
the request has been processed.


Students reset the LIBRARY Apache Derby database to its initial state. They then run the
application in order to discover the problem. The server is restarted in debug mode,
breakpoints are added, and the students uses the Step Over, Step Into and Step Return
options to view the execution.


Once the problem has been fixed by adding the line of code, the Step-by-Step debug mode
is used to check that the solution works.




8-2   Developing Web Applications                                                 © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty   Exercise instructions
          Preface
          Open the workspace and if necessary import the required projects (they will already be
          there if you are continuing from the previous lab).
          The following reference in the exercise instructions represents the directory location in your
          workstation:
                   • <LAB_FILES>: C:LabFiles70




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application         8-3
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide



8.1. Prepare the Workspace
The workspace used in the previous lab (Connecting to a Database) should be used as the
starting point for this lab.
If you skipped labs 1, 3 or 4, perform follow the instructions:
__ 1. Start Rational Application Developer.
      __ a. In the Workspace Launcher dialog, specify <LAB_FILES>workspace as the
            new workspace directory.
      __ b. Click OK to open the workspace.
      __ c. Import the <LAB_FILES>DatasolutionDatabaseSolution.zip file. If you need
            assistance, refer to the instructions in the Appendix, Install the Library
            Application in a New Workspace.




8-4    Developing Web Applications                                                © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty   8.2. Reset the Database to Its Default Values
          __ 2. Ensure that the Server is stopped, because the Derby database can only serve one
                client. When the server is running, the data source is the client, so no other program
                can access the database.
              __ a. Open the Servers view by selecting Window                       Show View          Servers.
              __ b. In the Servers view, make sure that the WebSphere Application Server V6.1
                    status is Stopped. If the status is Started, right-click the server and select Stop
                    to stop the server.




          __ 3. Run SetUpLibraryDatabase.java.
              __ a. In the Project Explorer view, expand LibraryDatabaseSetup                           driver.
              __ b. Right-click SetUpLibraryDatabase.java and select Run As                            Java
                    Application.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application         8-5
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide


      __ c. The result should be displayed in the Console view.




      __ d. The message indicates that the library database has successfully reverted to its
            original values.




8-6    Developing Web Applications                                                © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty   8.3. Discover the Problem with Consecutive Check Outs
          __ 4. Search for the Patron with e-mail dv@bogus.ibm.com.
              __ a. In the Project Explorer, expand LibraryWeb                    WebContent.
              __ b. Right click search.jsp and select Run As                   Run on Server.
              __ c. Once the server has started and the search page is loaded in the Web browser,
                    enter dv@bogus.ibm.com as the Search Phrase and select E-mail as the
                    Criteria.




              __ d. Click Search.
          __ 5. Perform consecutive renewal for a different set of items.
              __ a. In the search result page, take note of the due date for the items, then select the
                    first and second check box.




              __ b. Click Renew.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application         8-7
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide




              Note

Results may vary, based upon the date the database was last refreshed and the date when
Renew is clicked.
This applies to all subsequent results displayed in this lab.



      __ c. The first two items are updated with Renewal Status, and the Due Date for the
            second book has been extended.
            Select the third check box, leaving the first two items unchecked.




      __ d. Click Renew again.
      __ e. Notice this time, even though the second item was not selected for Renewal, the
            minute recorded for the transaction time has been extended again. As well, the
            first item still shows the Maximum number of renewals exceeded message when
            it was not requested for renewal.




      __ f.   This time leave all the check boxes cleared, and click Renew twice. The
              following screen appears. Notice the second item is declared to exceed the


8-8    Developing Web Applications                                                © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty               maximum number of renewals even though it was never selected for renewal
                      after the first trial.




              __ g. Clearly, submitting the form several times consecutively produces logical errors
                    in the program. You will now debug this application to determine the cause of the
                    error.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application         8-9
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide



8.4. Debug the Application
__ 6. In order to duplicate the scenario, you must reset the database to its default values.
      You can do so by following the instructions outlined in Section 7.2.
__ 7. Restart the WebSphere Application Server in debug mode.
    __ a. Open the Servers view.
    __ b. Right-click the WebSphere Application Server V6.1 entry and select Debug if the
          server is stopped or Restart Debug if the server is already running.
    __ c. When the server has restarted, you will notice the status of the server now
          indicates that the server is running in debug mode.




__ 8. Since the logic error occurs when renewing the items, the error is likely to be in the
      RenewItems servlet or in an object called from that servlet. Set breakpoints in the
      RenewItems servlet.
    __ a. In the Project Explorer view, navigate to LibraryWeb                       Java Resources: src
             com.ibm.library.servlets.
    __ b. Double-click RenewItems to open it in the editor.
    __ c. The logic in RenewItems is concentrated in the processRequest method. So
          the breakpoint should be set inside that method.
          Further examining of the method reveals that the first few statements are general
          setup statements. They should not cause any problems. The breakpoint should
          therefore be placed at the first statement in the try block.
    __ d. Type CTRL-L and enter 74 in the Go to Line dialog to reach the following
          statement:
                    Collection loanList =
                    (Collection)session.getAttribute("itemList");




8-10 Developing Web Applications                                                  © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty       __ e. Double-click the vertical ruler on the left of the editor, next to line 74 of the code,
                    to set a breakpoint at this line. A breakpoint marker now appears on the mark
                    bar.




              __ f.   A good practice when debugging is to set breakpoints further down in the source
                      than your original stopping point. This way, when you determine the problem is
                      not in the section you are currently debugging, you can click the run button to
                      skip to the next breakpoint without stopping. Scroll down to line 91 (you can use
                      CTRL-L) and place a breakpoint beside the following statement:
                              context.getRequestDispatcher("/listitems.jsp").forward(req,
                              resp);




          __ 9. Debug the Library application on the server.
              __ a. In the Project Explorer view, expand LibraryWeb                      WebContent.
              __ b. Right-click search.jsp and select Debug As                     Debug on Server from the
                    pop-up menu.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application       8-11
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide


    __ c. Once the search page shows up in the browser, enter dv@bogus.ibm.com as
          the Search Phrase and select E-mail as the Criteria. Click Search.




    __ d. The item list page now shows up. Select the first and second item, and click
          Renew.




    __ e. When asked to switch to the Debug perspective, click Yes.
    __ f.   The RenewItems servlet is triggered and the first breakpoint is hit. Click the
            RenewItems.java tab and scroll to line 74, the breakpoint line is highlighted.




8-12 Developing Web Applications                                                  © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty       __ g. You know the renewal process is fine the first time, so you can skip over to the
                    next breakpoint by clicking the Resume button in the Debug view.




              __ h. With the current execution halted on the context.getRequestDispatcher
                    statement, you can examine the variables resulting from the previous
                    statements.
              __ i.   In the Variables view, expand loanList elementData [0], and note the
                      renewAccomplished, renewMessage, and renewRequested variables.
                      Those are the ones of interest to this debugging session.




              __ j.   Expand element [1] and [2] in the elementData array and examine their fields.
                      Notice that the renewRequested variable is set to true, true, false for
                      the three items in the array.
              __ k. Click the Resume button run the servlet to completion.
              __ l.   Switch to the Web browser, it should now display the Renewal Status for the
                      first two items.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application       8-13
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide


    __ m. Select the third row, and leave the first two rows clear. Click Renew.




    __ n. The debugger should take you to the first breakpoint in RenewItems.java again.
__ 10. Use the various Step commands to examine the variables in the servlet. Note that
       loanList is not yet declared.
    __ a. Click Step Over in the Debug view toolbar to go to the next statement in the
          processRequest method.



    __ b. Now loanList should appear in the Variables view. Expand it to examine the
          items in the list. Notice for elementData[0], the renewRequested value is still
          set to true.




8-14 Developing Web Applications                                                  © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty
                      Note

          Note that the ids in the previous Variables view, will vary between executions and
          workspaces.



              __ c. Click the Step Over button to step over the statement String[] renewList
                    = req.getParameterValues("RENEW_ITEM");.
              __ d. Examine the renewList variable in the Variables view. It should just contain
                    one element, and that element has a value of 4.




              __ e. With the execution halted on the markRenewed method, click Step Into in the
                    Debug view to move the execution to the first line of the markRenewed method.



              __ f.   In the markRenewed method, highlight the line
                      if (Integer.valueOf(renewList[i]).intValue() == itemId) {
                      Right-click it and select Run to Line to move the execution to this particular
                      statement.




              __ g. You can also evaluate the current if statement without stepping over it. Open
                    the Display view by selecting Window Show View Display. Copy and paste
                    the if statement Integer.valueOf(renewList[i]).intValue() ==
                    itemId to the Display view. Highlight the expression in Display view and select
                    Display from the pop-up menu. The result should be displayed on the next line.
                    The value false means that the first item does not match the renew list.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application       8-15
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide


    __ h. Back in the RenewItems.java editor, highlight the line
          copy.setRenewRequested(true);. Right-click it and select Run to Line.
    __ i.   In the Variables view, expand copy = LoanedCopy to see that its itemId
            matches the itemId local variable.




    __ j.   Click Step Return in the Debug view to return the execution back to the
            processRequest method.



    __ k. The Debug Current Instruction Pointer should now point to the
          patron.renew(loanList); line. This instruction will execute the renew
          command on database, so you need to make sure the data passed in are setup
          correctly.
__ 11. Change the variable values in a debugging session.
    __ a. In the Variables view, expand loanList elementData [0], [1], [2]. Notice that
          the renewRequested variable is set to true, true, true for the three




8-16 Developing Web Applications                                                  © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty               LoanedCopy elements. Since you only requested that the third book be
                      renewed, the correct values should be false, false, true.




              __ b. Right-click the renewRequested variable under elementData                              [0] and select
                    Change Value.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application       8-17
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide


    __ c. In the Set Value dialog, enter false. Click OK.




    __ d. Similarly, right-click elementData [1] renewRequested and select Change
          Value. Enter false in the Set Value dialog, and click OK.
    __ e. Now the Variables view should have the three renewRequested variables at
          false, false, true as desired.
    __ f.   Click Step Over to execute the patron.renew instruction.
    __ g. Back in the Variables view, you should see that elementData[1] has
          renewMessage= "&nbsp;". Meaning this copy did not get renewed
          unnecessarily.
    __ h. Click the Resume button twice to finish executing the servlet.
    __ i.   Switch to the Web browser and the following screen should show. This is the
            correct behavior for renewing the third item.




8-18 Developing Web Applications                                                  © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty   8.5. Fix the Mistake
          By setting the renewRequested variable to false for the non-selected LoanedCopy
          elements, you corrected the logic error in the debugging session.
          To implement this change in the code, you need to reset all the renewRequested
          variables to false by default.
          __ 12. One way to do this is to add the line copy.setRenewRequested(false); at the
                 end of the first while loop of the markRenew method. The change should look like
                 the following.




          __ 13. Save the changes.

                      Note

          The new class should be automatically republished by the server.
          There is no need to manually restart the server or application.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application       8-19
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide



8.6. Step-by-Step Debugging
__ 14. Perform Step-by-Step debugging.
    __ a. Open the Breakpoints view (on the same tab set as the Variables view), and
          clear all of the check boxes to temporarily disable the breakpoints.




    __ b. Click on the listitems tab to select the Web browser, type
          http://localhost:9080/Library/search.jsp in the address bar, press
          ENTER.
    __ c. In the search page, enter dv@bogus.ibm.com in Search Phrase, select
          E-mail, and click Search. The list items page should now be loaded in the
          browser.
    __ d. In the Web browser, select all three books for renewal, and click Renew.
    __ e. In the Debug view, select the root element WebSphere Application Server
          v6.1, and click the Enable Step-by-Step Mode icon.




    __ f.   In the Web browser, leave all of the check boxes clear, and click Renew.




8-20 Developing Web Applications                                                  © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty       __ g. A Step-by-Step Debug dialog appears asking you whether to step into the
                    com.ibm.library.servlets.RenewItems.doPost method. Select Step
                    into, and click OK.




              __ h. The execution should now be halted on the processRequest(req, resp);
                    line of the doPost method.
              __ i.   Scroll down the page to line 90, session.setAttribute("itemList",
                      loanList);. Highlight the line and select Run to Line to move the execution
                      just before the session attribute is set.
              __ j.   In the Variables view, examine the content of loanlist. The renewMessage
                      and renewRequested variables should have the values of &nbsp and false.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application       8-21
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide


            Having these results means that the previous logical error of submitting empty
            check boxes has been fixed.




    __ k. Click the Resume button in Debug view to continue execution.
__ 15. Debug a JSP page.




8-22 Developing Web Applications                                                  © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.
V4.1
                                                                                                   Instructor Exercises Guide



EXempty       __ a. A Step-by-Step Debug dialog appears again, asking whether to step into
                    com.ibm._jsp._listitems._jspService. Select Step Into and click OK
                    to step into the JSP page.




              __ b. The JSP page listitems.jsp is loaded in the editor. Click Step Over twice to
                    reach the <jsp:getProperty> tag.
              __ c. Notice in the Variables view, a PATRON object becomes available as a result of
                    the <jsp:useBean> tag.




              __ d. Click Resume to continue executing the JSP page.




          © Copyright IBM Corp. 2004, 2007                                    Exercise 8. Debug a Web Application       8-23
                                      Course materials may not be reproduced in whole or in part
                                             without the prior written permission of IBM.
Instructor Exercises Guide


    __ e. Switch to the Web browser, there should be no messages under the Renew
          Status column.




__ 16. Stop the Server. In the Servers view, right-click the server and select Stop.

End of exercise




8-24 Developing Web Applications                                                  © Copyright IBM Corp. 2004, 2007
                             Course materials may not be reproduced in whole or in part
                                    without the prior written permission of IBM.

Weitere ähnliche Inhalte

Was ist angesagt?

EMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design PatternsEMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design PatternsHaytham Ghandour
 
EMC Documentum - xCP 2.x Troubleshooting
EMC Documentum - xCP 2.x TroubleshootingEMC Documentum - xCP 2.x Troubleshooting
EMC Documentum - xCP 2.x TroubleshootingHaytham Ghandour
 
EMC Documentum xCP 2.x Tips for application migration v1.1
EMC Documentum xCP 2.x Tips for application migration v1.1EMC Documentum xCP 2.x Tips for application migration v1.1
EMC Documentum xCP 2.x Tips for application migration v1.1Haytham Ghandour
 
Module 3: Working with Jazz Source Control
Module 3: Working with Jazz Source ControlModule 3: Working with Jazz Source Control
Module 3: Working with Jazz Source ControlIBM Rational software
 
Module 2: Managing Work Items in Rational Team Concert
Module 2: Managing Work Items in Rational Team ConcertModule 2: Managing Work Items in Rational Team Concert
Module 2: Managing Work Items in Rational Team ConcertIBM Rational software
 
Java EE 7 Recipes
Java EE 7 RecipesJava EE 7 Recipes
Java EE 7 RecipesJosh Juneau
 
Tutorial: Create a custom work item in Rational Team Concert
Tutorial: Create a custom work item in Rational Team ConcertTutorial: Create a custom work item in Rational Team Concert
Tutorial: Create a custom work item in Rational Team ConcertBill Duncan
 
Create software builds with jazz team build
Create software builds with jazz team buildCreate software builds with jazz team build
Create software builds with jazz team buildBill Duncan
 
Business Solutions Using Office Share Point Server2007
Business Solutions Using Office Share Point Server2007Business Solutions Using Office Share Point Server2007
Business Solutions Using Office Share Point Server2007LiquidHub
 
Portal at the Speed of Light
Portal at the Speed of LightPortal at the Speed of Light
Portal at the Speed of LightProlifics
 
Migration & upgrades best practice upgrade pathways to emc documentum 7
Migration & upgrades   best practice upgrade pathways to emc documentum 7Migration & upgrades   best practice upgrade pathways to emc documentum 7
Migration & upgrades best practice upgrade pathways to emc documentum 7Haytham Ghandour
 
9.16.2013 Enlightenment Series - Managing parallel development with RTC: A st...
9.16.2013 Enlightenment Series - Managing parallel development with RTC: A st...9.16.2013 Enlightenment Series - Managing parallel development with RTC: A st...
9.16.2013 Enlightenment Series - Managing parallel development with RTC: A st...IBM Rational
 
PowerPoint Presentation
PowerPoint PresentationPowerPoint Presentation
PowerPoint Presentationrhofkens
 

Was ist angesagt? (20)

Lab4 RTC Builds
Lab4 RTC BuildsLab4 RTC Builds
Lab4 RTC Builds
 
EMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design PatternsEMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design Patterns
 
EMC Documentum - xCP 2.x Troubleshooting
EMC Documentum - xCP 2.x TroubleshootingEMC Documentum - xCP 2.x Troubleshooting
EMC Documentum - xCP 2.x Troubleshooting
 
Lab3 RTC Source Control
Lab3 RTC Source ControlLab3 RTC Source Control
Lab3 RTC Source Control
 
Lab2 RTC Work Items
Lab2 RTC Work ItemsLab2 RTC Work Items
Lab2 RTC Work Items
 
Lab1 RTC Overview
Lab1 RTC OverviewLab1 RTC Overview
Lab1 RTC Overview
 
Dacj 2-2 a
Dacj 2-2 aDacj 2-2 a
Dacj 2-2 a
 
EMC Documentum xCP 2.x Tips for application migration v1.1
EMC Documentum xCP 2.x Tips for application migration v1.1EMC Documentum xCP 2.x Tips for application migration v1.1
EMC Documentum xCP 2.x Tips for application migration v1.1
 
Module 3: Working with Jazz Source Control
Module 3: Working with Jazz Source ControlModule 3: Working with Jazz Source Control
Module 3: Working with Jazz Source Control
 
Module 2: Managing Work Items in Rational Team Concert
Module 2: Managing Work Items in Rational Team ConcertModule 2: Managing Work Items in Rational Team Concert
Module 2: Managing Work Items in Rational Team Concert
 
Resource lab
Resource labResource lab
Resource lab
 
Java EE 7 Recipes
Java EE 7 RecipesJava EE 7 Recipes
Java EE 7 Recipes
 
Tutorial: Create a custom work item in Rational Team Concert
Tutorial: Create a custom work item in Rational Team ConcertTutorial: Create a custom work item in Rational Team Concert
Tutorial: Create a custom work item in Rational Team Concert
 
Create software builds with jazz team build
Create software builds with jazz team buildCreate software builds with jazz team build
Create software builds with jazz team build
 
Business Solutions Using Office Share Point Server2007
Business Solutions Using Office Share Point Server2007Business Solutions Using Office Share Point Server2007
Business Solutions Using Office Share Point Server2007
 
Portal at the Speed of Light
Portal at the Speed of LightPortal at the Speed of Light
Portal at the Speed of Light
 
Migration & upgrades best practice upgrade pathways to emc documentum 7
Migration & upgrades   best practice upgrade pathways to emc documentum 7Migration & upgrades   best practice upgrade pathways to emc documentum 7
Migration & upgrades best practice upgrade pathways to emc documentum 7
 
Lab5 RTC reports and Dashboards
Lab5 RTC reports and DashboardsLab5 RTC reports and Dashboards
Lab5 RTC reports and Dashboards
 
9.16.2013 Enlightenment Series - Managing parallel development with RTC: A st...
9.16.2013 Enlightenment Series - Managing parallel development with RTC: A st...9.16.2013 Enlightenment Series - Managing parallel development with RTC: A st...
9.16.2013 Enlightenment Series - Managing parallel development with RTC: A st...
 
PowerPoint Presentation
PowerPoint PresentationPowerPoint Presentation
PowerPoint Presentation
 

Ähnlich wie Lab 7a) debug a web application

Lab 7b) test a web application
Lab 7b) test a web applicationLab 7b) test a web application
Lab 7b) test a web applicationtechbed
 
Lab 5a) create a struts application
Lab 5a) create a struts applicationLab 5a) create a struts application
Lab 5a) create a struts applicationtechbed
 
Part 6 debugging and testing java applications
Part 6 debugging and testing java applicationsPart 6 debugging and testing java applications
Part 6 debugging and testing java applicationstechbed
 
Lab 3) create a web application
Lab 3) create a web applicationLab 3) create a web application
Lab 3) create a web applicationtechbed
 
Part 3 web development
Part 3 web developmentPart 3 web development
Part 3 web developmenttechbed
 
F7 wc9 zu3701lsg_ai
F7 wc9 zu3701lsg_aiF7 wc9 zu3701lsg_ai
F7 wc9 zu3701lsg_aipiano_girl
 
Part 5 running java applications
Part 5 running java applicationsPart 5 running java applications
Part 5 running java applicationstechbed
 
Business Solutions Using Office Share Point Server2007
Business Solutions Using Office Share Point Server2007Business Solutions Using Office Share Point Server2007
Business Solutions Using Office Share Point Server2007LiquidHub
 
Tivoli perfviewer
Tivoli perfviewerTivoli perfviewer
Tivoli perfvieweritsolvs
 
Bea weblogic job_interview_preparation_guide
Bea weblogic job_interview_preparation_guideBea weblogic job_interview_preparation_guide
Bea weblogic job_interview_preparation_guidePankaj Singh
 
Free EJB Tutorial | VirtualNuggets
Free EJB Tutorial | VirtualNuggetsFree EJB Tutorial | VirtualNuggets
Free EJB Tutorial | VirtualNuggetsVirtual Nuggets
 
Installing ibm tivoli directory server v6.0 (web sphere partner gateway v6.1 ...
Installing ibm tivoli directory server v6.0 (web sphere partner gateway v6.1 ...Installing ibm tivoli directory server v6.0 (web sphere partner gateway v6.1 ...
Installing ibm tivoli directory server v6.0 (web sphere partner gateway v6.1 ...Banking at Ho Chi Minh city
 
Myeclipse+Eclipse+J Boss开发Ejb
Myeclipse+Eclipse+J Boss开发EjbMyeclipse+Eclipse+J Boss开发Ejb
Myeclipse+Eclipse+J Boss开发Ejbyiditushe
 

Ähnlich wie Lab 7a) debug a web application (20)

Lab 7b) test a web application
Lab 7b) test a web applicationLab 7b) test a web application
Lab 7b) test a web application
 
Lab 5a) create a struts application
Lab 5a) create a struts applicationLab 5a) create a struts application
Lab 5a) create a struts application
 
Part 6 debugging and testing java applications
Part 6 debugging and testing java applicationsPart 6 debugging and testing java applications
Part 6 debugging and testing java applications
 
Lab 3) create a web application
Lab 3) create a web applicationLab 3) create a web application
Lab 3) create a web application
 
Part 3 web development
Part 3 web developmentPart 3 web development
Part 3 web development
 
F7 wc9 zu3701lsg_ai
F7 wc9 zu3701lsg_aiF7 wc9 zu3701lsg_ai
F7 wc9 zu3701lsg_ai
 
Resourceslab fixed
Resourceslab fixedResourceslab fixed
Resourceslab fixed
 
Part 5 running java applications
Part 5 running java applicationsPart 5 running java applications
Part 5 running java applications
 
Business Solutions Using Office Share Point Server2007
Business Solutions Using Office Share Point Server2007Business Solutions Using Office Share Point Server2007
Business Solutions Using Office Share Point Server2007
 
os-php-wiki5-a4
os-php-wiki5-a4os-php-wiki5-a4
os-php-wiki5-a4
 
os-php-wiki5-a4
os-php-wiki5-a4os-php-wiki5-a4
os-php-wiki5-a4
 
Tivoli perfviewer
Tivoli perfviewerTivoli perfviewer
Tivoli perfviewer
 
Bea weblogic job_interview_preparation_guide
Bea weblogic job_interview_preparation_guideBea weblogic job_interview_preparation_guide
Bea weblogic job_interview_preparation_guide
 
Free EJB Tutorial | VirtualNuggets
Free EJB Tutorial | VirtualNuggetsFree EJB Tutorial | VirtualNuggets
Free EJB Tutorial | VirtualNuggets
 
Security lab
Security labSecurity lab
Security lab
 
Modular enablement
Modular enablementModular enablement
Modular enablement
 
Installing ibm tivoli directory server v6.0 (web sphere partner gateway v6.1 ...
Installing ibm tivoli directory server v6.0 (web sphere partner gateway v6.1 ...Installing ibm tivoli directory server v6.0 (web sphere partner gateway v6.1 ...
Installing ibm tivoli directory server v6.0 (web sphere partner gateway v6.1 ...
 
WebLogic FAQs
WebLogic FAQsWebLogic FAQs
WebLogic FAQs
 
Refresh controller
Refresh controllerRefresh controller
Refresh controller
 
Myeclipse+Eclipse+J Boss开发Ejb
Myeclipse+Eclipse+J Boss开发EjbMyeclipse+Eclipse+J Boss开发Ejb
Myeclipse+Eclipse+J Boss开发Ejb
 

Mehr von techbed

1456.base boot
1456.base boot1456.base boot
1456.base boottechbed
 
1455.ata atapi standards - 1-7
1455.ata atapi standards - 1-71455.ata atapi standards - 1-7
1455.ata atapi standards - 1-7techbed
 
1454.ata features
1454.ata features1454.ata features
1454.ata featurestechbed
 
1432.encoding concepts
1432.encoding concepts1432.encoding concepts
1432.encoding conceptstechbed
 
Flash cs4 tutorials_2009
Flash cs4 tutorials_2009Flash cs4 tutorials_2009
Flash cs4 tutorials_2009techbed
 
Photoshop tut
Photoshop tutPhotoshop tut
Photoshop tuttechbed
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_entechbed
 
Part 7 packaging and deployment
Part 7 packaging and deploymentPart 7 packaging and deployment
Part 7 packaging and deploymenttechbed
 
First java-server-faces-tutorial-en
First java-server-faces-tutorial-enFirst java-server-faces-tutorial-en
First java-server-faces-tutorial-entechbed
 
Part 4 working with databases
Part 4 working with databasesPart 4 working with databases
Part 4 working with databasestechbed
 
Lab 1) rad installation
Lab 1) rad installationLab 1) rad installation
Lab 1) rad installationtechbed
 
6) debugging and testing
6) debugging and testing6) debugging and testing
6) debugging and testingtechbed
 
7) packaging and deployment
7) packaging and deployment7) packaging and deployment
7) packaging and deploymenttechbed
 
5) running applications
5) running applications5) running applications
5) running applicationstechbed
 
4) databases
4) databases4) databases
4) databasestechbed
 
3) web development
3) web development3) web development
3) web developmenttechbed
 
2009 ibm academic initiative
2009 ibm academic initiative2009 ibm academic initiative
2009 ibm academic initiativetechbed
 
2) java development
2) java development2) java development
2) java developmenttechbed
 

Mehr von techbed (18)

1456.base boot
1456.base boot1456.base boot
1456.base boot
 
1455.ata atapi standards - 1-7
1455.ata atapi standards - 1-71455.ata atapi standards - 1-7
1455.ata atapi standards - 1-7
 
1454.ata features
1454.ata features1454.ata features
1454.ata features
 
1432.encoding concepts
1432.encoding concepts1432.encoding concepts
1432.encoding concepts
 
Flash cs4 tutorials_2009
Flash cs4 tutorials_2009Flash cs4 tutorials_2009
Flash cs4 tutorials_2009
 
Photoshop tut
Photoshop tutPhotoshop tut
Photoshop tut
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_en
 
Part 7 packaging and deployment
Part 7 packaging and deploymentPart 7 packaging and deployment
Part 7 packaging and deployment
 
First java-server-faces-tutorial-en
First java-server-faces-tutorial-enFirst java-server-faces-tutorial-en
First java-server-faces-tutorial-en
 
Part 4 working with databases
Part 4 working with databasesPart 4 working with databases
Part 4 working with databases
 
Lab 1) rad installation
Lab 1) rad installationLab 1) rad installation
Lab 1) rad installation
 
6) debugging and testing
6) debugging and testing6) debugging and testing
6) debugging and testing
 
7) packaging and deployment
7) packaging and deployment7) packaging and deployment
7) packaging and deployment
 
5) running applications
5) running applications5) running applications
5) running applications
 
4) databases
4) databases4) databases
4) databases
 
3) web development
3) web development3) web development
3) web development
 
2009 ibm academic initiative
2009 ibm academic initiative2009 ibm academic initiative
2009 ibm academic initiative
 
2) java development
2) java development2) java development
2) java development
 

Kürzlich hochgeladen

Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 

Kürzlich hochgeladen (20)

Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 

Lab 7a) debug a web application

  • 1. V4.1 Instructor Exercises Guide EXempty Exercise 8. Debug a Web Application Estimated time 00:45 What this exercise is about In this exercise, you debug the Web application running in the integrated test environment. IBM Rational Application Developer (V7 and later) includes an integrated testing and debugging environment that can be used to debug J2EE applications. What you should be able to do At the end of the exercise, you will be able to: • Set up the Test Environment for debugging • Debug the application in Rational Application Developer Introduction The J2EE application that is debugged in this exercise is the library book renewal application. It is composed of a Web application with an associated Java utility module. Before the application can be debugged, the server needs to be started in debug mode. Requirements This exercise requires that the library Web project be implemented (Labs 1-4) and the library database installed (Lab 1). If the earlier labs were not completed, import the <LAB_FILES>DatabasesolutionDatabaseSolution.zip file. The library database needs to be re-installed, but this will be done as part of this exercise. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-1 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 2. Instructor Exercises Guide Instructor exercise overview In this exercise students will discover an error into the library enterprise application, and will use the debugging features of IBM Rational Application Developer to find the source of the error. Students discover that renewals are being processed even if no renewal period was requested. This is caused by the renewRequested variable keeping a value of true once it has been set. The solution is to add a line of code to reset the variable to false as soon as the request has been processed. Students reset the LIBRARY Apache Derby database to its initial state. They then run the application in order to discover the problem. The server is restarted in debug mode, breakpoints are added, and the students uses the Step Over, Step Into and Step Return options to view the execution. Once the problem has been fixed by adding the line of code, the Step-by-Step debug mode is used to check that the solution works. 8-2 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 3. V4.1 Instructor Exercises Guide EXempty Exercise instructions Preface Open the workspace and if necessary import the required projects (they will already be there if you are continuing from the previous lab). The following reference in the exercise instructions represents the directory location in your workstation: • <LAB_FILES>: C:LabFiles70 © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-3 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 4. Instructor Exercises Guide 8.1. Prepare the Workspace The workspace used in the previous lab (Connecting to a Database) should be used as the starting point for this lab. If you skipped labs 1, 3 or 4, perform follow the instructions: __ 1. Start Rational Application Developer. __ a. In the Workspace Launcher dialog, specify <LAB_FILES>workspace as the new workspace directory. __ b. Click OK to open the workspace. __ c. Import the <LAB_FILES>DatasolutionDatabaseSolution.zip file. If you need assistance, refer to the instructions in the Appendix, Install the Library Application in a New Workspace. 8-4 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 5. V4.1 Instructor Exercises Guide EXempty 8.2. Reset the Database to Its Default Values __ 2. Ensure that the Server is stopped, because the Derby database can only serve one client. When the server is running, the data source is the client, so no other program can access the database. __ a. Open the Servers view by selecting Window Show View Servers. __ b. In the Servers view, make sure that the WebSphere Application Server V6.1 status is Stopped. If the status is Started, right-click the server and select Stop to stop the server. __ 3. Run SetUpLibraryDatabase.java. __ a. In the Project Explorer view, expand LibraryDatabaseSetup driver. __ b. Right-click SetUpLibraryDatabase.java and select Run As Java Application. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-5 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 6. Instructor Exercises Guide __ c. The result should be displayed in the Console view. __ d. The message indicates that the library database has successfully reverted to its original values. 8-6 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 7. V4.1 Instructor Exercises Guide EXempty 8.3. Discover the Problem with Consecutive Check Outs __ 4. Search for the Patron with e-mail dv@bogus.ibm.com. __ a. In the Project Explorer, expand LibraryWeb WebContent. __ b. Right click search.jsp and select Run As Run on Server. __ c. Once the server has started and the search page is loaded in the Web browser, enter dv@bogus.ibm.com as the Search Phrase and select E-mail as the Criteria. __ d. Click Search. __ 5. Perform consecutive renewal for a different set of items. __ a. In the search result page, take note of the due date for the items, then select the first and second check box. __ b. Click Renew. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-7 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 8. Instructor Exercises Guide Note Results may vary, based upon the date the database was last refreshed and the date when Renew is clicked. This applies to all subsequent results displayed in this lab. __ c. The first two items are updated with Renewal Status, and the Due Date for the second book has been extended. Select the third check box, leaving the first two items unchecked. __ d. Click Renew again. __ e. Notice this time, even though the second item was not selected for Renewal, the minute recorded for the transaction time has been extended again. As well, the first item still shows the Maximum number of renewals exceeded message when it was not requested for renewal. __ f. This time leave all the check boxes cleared, and click Renew twice. The following screen appears. Notice the second item is declared to exceed the 8-8 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 9. V4.1 Instructor Exercises Guide EXempty maximum number of renewals even though it was never selected for renewal after the first trial. __ g. Clearly, submitting the form several times consecutively produces logical errors in the program. You will now debug this application to determine the cause of the error. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-9 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 10. Instructor Exercises Guide 8.4. Debug the Application __ 6. In order to duplicate the scenario, you must reset the database to its default values. You can do so by following the instructions outlined in Section 7.2. __ 7. Restart the WebSphere Application Server in debug mode. __ a. Open the Servers view. __ b. Right-click the WebSphere Application Server V6.1 entry and select Debug if the server is stopped or Restart Debug if the server is already running. __ c. When the server has restarted, you will notice the status of the server now indicates that the server is running in debug mode. __ 8. Since the logic error occurs when renewing the items, the error is likely to be in the RenewItems servlet or in an object called from that servlet. Set breakpoints in the RenewItems servlet. __ a. In the Project Explorer view, navigate to LibraryWeb Java Resources: src com.ibm.library.servlets. __ b. Double-click RenewItems to open it in the editor. __ c. The logic in RenewItems is concentrated in the processRequest method. So the breakpoint should be set inside that method. Further examining of the method reveals that the first few statements are general setup statements. They should not cause any problems. The breakpoint should therefore be placed at the first statement in the try block. __ d. Type CTRL-L and enter 74 in the Go to Line dialog to reach the following statement: Collection loanList = (Collection)session.getAttribute("itemList"); 8-10 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 11. V4.1 Instructor Exercises Guide EXempty __ e. Double-click the vertical ruler on the left of the editor, next to line 74 of the code, to set a breakpoint at this line. A breakpoint marker now appears on the mark bar. __ f. A good practice when debugging is to set breakpoints further down in the source than your original stopping point. This way, when you determine the problem is not in the section you are currently debugging, you can click the run button to skip to the next breakpoint without stopping. Scroll down to line 91 (you can use CTRL-L) and place a breakpoint beside the following statement: context.getRequestDispatcher("/listitems.jsp").forward(req, resp); __ 9. Debug the Library application on the server. __ a. In the Project Explorer view, expand LibraryWeb WebContent. __ b. Right-click search.jsp and select Debug As Debug on Server from the pop-up menu. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-11 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 12. Instructor Exercises Guide __ c. Once the search page shows up in the browser, enter dv@bogus.ibm.com as the Search Phrase and select E-mail as the Criteria. Click Search. __ d. The item list page now shows up. Select the first and second item, and click Renew. __ e. When asked to switch to the Debug perspective, click Yes. __ f. The RenewItems servlet is triggered and the first breakpoint is hit. Click the RenewItems.java tab and scroll to line 74, the breakpoint line is highlighted. 8-12 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 13. V4.1 Instructor Exercises Guide EXempty __ g. You know the renewal process is fine the first time, so you can skip over to the next breakpoint by clicking the Resume button in the Debug view. __ h. With the current execution halted on the context.getRequestDispatcher statement, you can examine the variables resulting from the previous statements. __ i. In the Variables view, expand loanList elementData [0], and note the renewAccomplished, renewMessage, and renewRequested variables. Those are the ones of interest to this debugging session. __ j. Expand element [1] and [2] in the elementData array and examine their fields. Notice that the renewRequested variable is set to true, true, false for the three items in the array. __ k. Click the Resume button run the servlet to completion. __ l. Switch to the Web browser, it should now display the Renewal Status for the first two items. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-13 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 14. Instructor Exercises Guide __ m. Select the third row, and leave the first two rows clear. Click Renew. __ n. The debugger should take you to the first breakpoint in RenewItems.java again. __ 10. Use the various Step commands to examine the variables in the servlet. Note that loanList is not yet declared. __ a. Click Step Over in the Debug view toolbar to go to the next statement in the processRequest method. __ b. Now loanList should appear in the Variables view. Expand it to examine the items in the list. Notice for elementData[0], the renewRequested value is still set to true. 8-14 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 15. V4.1 Instructor Exercises Guide EXempty Note Note that the ids in the previous Variables view, will vary between executions and workspaces. __ c. Click the Step Over button to step over the statement String[] renewList = req.getParameterValues("RENEW_ITEM");. __ d. Examine the renewList variable in the Variables view. It should just contain one element, and that element has a value of 4. __ e. With the execution halted on the markRenewed method, click Step Into in the Debug view to move the execution to the first line of the markRenewed method. __ f. In the markRenewed method, highlight the line if (Integer.valueOf(renewList[i]).intValue() == itemId) { Right-click it and select Run to Line to move the execution to this particular statement. __ g. You can also evaluate the current if statement without stepping over it. Open the Display view by selecting Window Show View Display. Copy and paste the if statement Integer.valueOf(renewList[i]).intValue() == itemId to the Display view. Highlight the expression in Display view and select Display from the pop-up menu. The result should be displayed on the next line. The value false means that the first item does not match the renew list. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-15 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 16. Instructor Exercises Guide __ h. Back in the RenewItems.java editor, highlight the line copy.setRenewRequested(true);. Right-click it and select Run to Line. __ i. In the Variables view, expand copy = LoanedCopy to see that its itemId matches the itemId local variable. __ j. Click Step Return in the Debug view to return the execution back to the processRequest method. __ k. The Debug Current Instruction Pointer should now point to the patron.renew(loanList); line. This instruction will execute the renew command on database, so you need to make sure the data passed in are setup correctly. __ 11. Change the variable values in a debugging session. __ a. In the Variables view, expand loanList elementData [0], [1], [2]. Notice that the renewRequested variable is set to true, true, true for the three 8-16 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 17. V4.1 Instructor Exercises Guide EXempty LoanedCopy elements. Since you only requested that the third book be renewed, the correct values should be false, false, true. __ b. Right-click the renewRequested variable under elementData [0] and select Change Value. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-17 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 18. Instructor Exercises Guide __ c. In the Set Value dialog, enter false. Click OK. __ d. Similarly, right-click elementData [1] renewRequested and select Change Value. Enter false in the Set Value dialog, and click OK. __ e. Now the Variables view should have the three renewRequested variables at false, false, true as desired. __ f. Click Step Over to execute the patron.renew instruction. __ g. Back in the Variables view, you should see that elementData[1] has renewMessage= "&nbsp;". Meaning this copy did not get renewed unnecessarily. __ h. Click the Resume button twice to finish executing the servlet. __ i. Switch to the Web browser and the following screen should show. This is the correct behavior for renewing the third item. 8-18 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 19. V4.1 Instructor Exercises Guide EXempty 8.5. Fix the Mistake By setting the renewRequested variable to false for the non-selected LoanedCopy elements, you corrected the logic error in the debugging session. To implement this change in the code, you need to reset all the renewRequested variables to false by default. __ 12. One way to do this is to add the line copy.setRenewRequested(false); at the end of the first while loop of the markRenew method. The change should look like the following. __ 13. Save the changes. Note The new class should be automatically republished by the server. There is no need to manually restart the server or application. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-19 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 20. Instructor Exercises Guide 8.6. Step-by-Step Debugging __ 14. Perform Step-by-Step debugging. __ a. Open the Breakpoints view (on the same tab set as the Variables view), and clear all of the check boxes to temporarily disable the breakpoints. __ b. Click on the listitems tab to select the Web browser, type http://localhost:9080/Library/search.jsp in the address bar, press ENTER. __ c. In the search page, enter dv@bogus.ibm.com in Search Phrase, select E-mail, and click Search. The list items page should now be loaded in the browser. __ d. In the Web browser, select all three books for renewal, and click Renew. __ e. In the Debug view, select the root element WebSphere Application Server v6.1, and click the Enable Step-by-Step Mode icon. __ f. In the Web browser, leave all of the check boxes clear, and click Renew. 8-20 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 21. V4.1 Instructor Exercises Guide EXempty __ g. A Step-by-Step Debug dialog appears asking you whether to step into the com.ibm.library.servlets.RenewItems.doPost method. Select Step into, and click OK. __ h. The execution should now be halted on the processRequest(req, resp); line of the doPost method. __ i. Scroll down the page to line 90, session.setAttribute("itemList", loanList);. Highlight the line and select Run to Line to move the execution just before the session attribute is set. __ j. In the Variables view, examine the content of loanlist. The renewMessage and renewRequested variables should have the values of &nbsp and false. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-21 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 22. Instructor Exercises Guide Having these results means that the previous logical error of submitting empty check boxes has been fixed. __ k. Click the Resume button in Debug view to continue execution. __ 15. Debug a JSP page. 8-22 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 23. V4.1 Instructor Exercises Guide EXempty __ a. A Step-by-Step Debug dialog appears again, asking whether to step into com.ibm._jsp._listitems._jspService. Select Step Into and click OK to step into the JSP page. __ b. The JSP page listitems.jsp is loaded in the editor. Click Step Over twice to reach the <jsp:getProperty> tag. __ c. Notice in the Variables view, a PATRON object becomes available as a result of the <jsp:useBean> tag. __ d. Click Resume to continue executing the JSP page. © Copyright IBM Corp. 2004, 2007 Exercise 8. Debug a Web Application 8-23 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
  • 24. Instructor Exercises Guide __ e. Switch to the Web browser, there should be no messages under the Renew Status column. __ 16. Stop the Server. In the Servers view, right-click the server and select Stop. End of exercise 8-24 Developing Web Applications © Copyright IBM Corp. 2004, 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM.