29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

If password matches one in database, then successful login<br />

if (realPass.equals(pass)) {<br />

result = true;<br />

} else {<br />

try {<br />

common.LogWriter.getInstance().writeToLog("Login Error: Invalid<br />

password entered for " + user);<br />

} catch (InterruptedException ex) {}<br />

}//if<br />

}<br />

}<br />

// Close the connection<br />

rs.close();<br />

dbConnection.close();<br />

return result;<br />

} catch (Throwable e) {<br />

try {<br />

common.LogWriter.getInstance().writeToLog("Login Exception: " + e);<br />

return false;<br />

} catch (InterruptedException ex) {<br />

return result;<br />

}<br />

}<br />

Note: The login component illustrated in this section is only mentioned here to<br />

show the use of servlets in Studio Site Developer. The login component is not<br />

a proper Web site security solution and is not recommended for “real-life”<br />

situations. To reiterate, when the user logs in, a servlet will verify that the user<br />

and password exist in a database table and forward the user to a new page.<br />

No session information is used in the process, therefore if the user knew the<br />

full path of the location he or she could get there without using the login.<br />

Chapter 7. Working with servlets 239

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!