29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The following steps illustrate how to implement a form-based login.<br />

1. Create a login form. In this case we will create a login form called login.html.<br />

– The action required for the HTTP POST method is j_security_check. This<br />

method automatically registered on the level of the context root.<br />

– j_username should be the input field in which a user will write the user ID.<br />

– j_password should be the input filed into which a user will write the<br />

password.<br />

Example 16-1 shows a sample login form.<br />

Example 16-1 Sample custom login form<br />

<br />

<br />

<br />

Userid:<br />

<br />

Password:<br />

<br />

&nbsp;<br />

<br />

<br />

<br />

Note: The j_security_check servlet will not work when global security is<br />

disabled; the application server will return a page not found error. See<br />

“Enable <strong>WebSphere</strong> global security” on page 566.<br />

2. Open the Web deployment descriptor (web.xml) for the project and select the<br />

Pages tab.<br />

a. Enter a realm name.<br />

b. Click the drop-down list and select FORM as the authentication method.<br />

c. In the Login page click Browse and select login.html.<br />

d. In the Error page click Browse and select loginerror.html. (We have used<br />

the same page for log in and error. You can define a custom error.jsp page<br />

that will present an actual error code and error message.)<br />

3. Save and close the deployment descriptor.<br />

Chapter 16. Security 555

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

Saved successfully!

Ooh no, something went wrong!