Java Reference
In-Depth Information
FIGURE 12-49
Figure 12-50 displays lines 704 through 715 of the WebStocks servlet code.
This method returns a User object given a userID (line 704). The User object is
created by the StockTrackerDB method, getUser(), called within a synchronized
block of code (line 711). Recall that the StockTrackerDB method returns either
a User object or, if the userID does not exist, a null reference. The object
(reference) then is returned to where the method was called, as in line 306 on
page 816 in the logonValidated() method.
FIGURE 12-50
Figure 12-51 on the next page displays lines 716 through 747 of the
WebStocks servlet code. This method also returns an ArrayList containing user
data retrieved from the database. Again, method calls that access the database are
in a synchronized block of code (line 724). If a valid User object is obtained, the
required data is added to the ArrayList and then returned to the caller (lines 727
through 745). If a valid User object is not obtained, no user data is added to the
ArrayList; therefore, the size of the ArrayList is zero. This is used by the caller to
determine if any data was added to the list (line 155 on page 810 in the doPost()
method).
 
Search WWH ::




Custom Search