Overloading methods
There is another form of the getUsername and getPassword method
that we use, as in the listorder action in Section 3.7,  Accessing data
through a Java bean  on page 103, which retrieves the calue from the
HttpSession object. So, we also have the following method for
private String getUsername(HttpSession session) {
return session.getValue( username );
We have now overloaded the getUsername and getPassword methods.
These methods are distinguished by the parameter type being passed,
2. The next step is to verify if the username and password are valid. If not,
we must then call some sort of error routine and pass control back to a
failure page. Ideally, we could code it as follows:
if (!passwordsMatch(username, password)) {
uidPwdError(username, password, failurepage, req, res);
We need the passwordsMatch method to do the following:
a. Access the USERSTUF database
We assume the Connection object
has already been initialized.
b. Try to obtain a password for the provided username
We code this by selecting a password from the USERVERIFY table
based on the username. We then check that there is a result row
returned with the rs.next() method call, and ensure a valid password
has been returned by checking that the result set meta data has at
least one column as a result.
c. Return a value of true if the passwords match, false otherwise.
This is done by checking for string equality between the provided
password and the password found in the USERVERIFY table for the
Java code for the passwordsMatch method is shown in Figure 68 on page
Linux Web Hosting with WebSphere, DB2, and Domino



About Services Network Support FAQ Order Contact

Linux Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved