tags:

views:

203

answers:

3

After checking the database the incorrect password should be displayed on the same login page. I have used servlet and forwarded that to the login page but i couldn't add the message "incorrect password".

RequestDispatcher rd = getServletContext().getRequestDispatcher("/register.jsp");
if(dbpwd.equals(null)) {    
    pw.println("Not a registered user!!! sign up......");
    rd.forward(req,res);
}

In tha above snippet how to print the "Not a registered user sign up......" on the login page.

+2  A: 

As Bob Kaufman said, you need to change your error message to a more general one like : "incorrect username or password".

To display the message on the login page, get the response handler of your servlet, and write a tag with your message.

But for a more specific answer, please to specify your question.

enguerran
if the registered user enter an incorrect password the "incorrect password " should be displayed on the same login page.Eg: similar to gmail, if incorrect pwd is entered incorrect pwd message will be displayed......
gmail says: "The username or password you entered is incorrect."see : http://stackoverflow.com/questions/1172891
enguerran
+6  A: 

It's a very bad idea to tell a potentially malevolent user what he did wrong if he's attempting to gain access to your system with ill intent.

On the other hand, a legitimate user who receives a message stating, "The username or password you entered is incorrect" will, in most cases, be able to figure out what they did wrong, or contact support to resolve the issue. A hacker won't.

Don't go out of your way to help a hacker gain access by telling him which field he needs to correct to gain access.

Mike Hofer
this, times infinity
matt b
A: 

As others have said, you don't want to help someone trying to attack your application by providing a detailed error message for login pages.
You might find it useful to read this thread: What should a developer know before building a public web site?

macleojw