Java Reference
In-Depth Information
FIGURE 12-44
Figure 12-45 displays lines 614 through 626 of the WebStocks servlet code.
If the supplied userID is not null, then the database is accessed through the
StockTrackerDB object to get the corresponding User object for the userID
(line 621). This is necessary because the StockTrackerDB delUser() method,
used to delete a user from the database, requires a User object as an argument
(line 622). Because the User object is obtained from the database immediately
before deleting the user, and both of these calls are placed within a block of code
synchronized on the StockTrackerDB object, the delUser() method will be called
only for a valid, existing user. If the userID does not match an existing user, an
exception is thrown by the StockTrackerDB getUser() method.
FIGURE 12-45
Figure 12-46 displays lines 627 through 660 of the WebStocks servlet code.
This method obtains form data from parameters, much as does the addUser()
method (lines 632 through 637). Because it is updating an existing user, a User
object for the given userID is obtained from the database (line 641), and the
mutator methods for the various User fields are called to set their new values
(lines 644 through 655). If a new password value is supplied, however, the User
 
Search WWH ::




Custom Search