File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Form Based Authentication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Form Based Authentication" Watch "Form Based Authentication" New topic
Author

Form Based Authentication

carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

I have a login page with username and password fields whenever user enters wrong password i want to display an alert message, when i use form based authentication on error it goes to fail_login.html but i dont want that action to take place i want an alert and along with that it should display the index.html again.Can anybody suggest me how to do this .

[code]

<form-login-page>/index.html</form-login-page>
<form-error-page>/fail_login.html</form-error-page>
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi,

then, you can validate in servlet itself. why you want to go form based authentication?
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

yeah for that i did write a servlet, but my servlet is redirecting back to the login.html page, its not giving me the alert.

[code]
if(username.equals(loginname) && password.equals(pword))
{
session.setAttribute("UserName",username); response.sendRedirect("src/jsp/second.jsp");
}
else
{
response.sendRedirect("login.html");

}

here in else i can either give alert or redirect back to login.html but how do i get both, any suggestions please.
[ September 24, 2008: Message edited by: ruquia tabassum ]
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Originally posted by ruquia tabassum:

here in else i can either give alert or redirect back to login.html but how do i get both, any suggestions please.



Alert , you means a JavaScript alert . If thats your need then How come a response from servlet execute those Client side javascript alert !

May be you can simply show a line of text with error message stating "Invalid User Name OR Password !" , for that , your Login Action Servlet looks like this ,



and on jsp page ,


I hope that's solve your problem . Now still you want that alert to be shown on wrong user id and password , then I suggest go for AJAX !




[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Sagar Rohankar:



jsp page ,




you have to give !=
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

How can I miss that , anyways, Thanks seetharaman
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

you are welcome sagar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form Based Authentication