I have a login page which is validated at the server side.When the login fails,the servlet which does the processing calls the sendRedirect to the login jsp.I want to display some error message when the jsp is called back again with some message like "Login failed,Try again!" at a particular place on the login jsp.
Why are you using sendRedirect.Send redirect is normally used when you need to redirect the user to somewhere outside your application.Use RequestDispatcher instead and put any error messages in the request scope.
Joined: Nov 27, 2007
I used request dispatcher and send the attribute inside the req object to the page where I want to display the message.
It works for me now!!
Thanks for your advice!!
Joined: Mar 23, 2009
You are most welcomed.
Good that this worked for you.
Redirects are use liberally within the same web application when its appropriate to generate a new response.
Bear Bibeault i didnt have the chance or need to use sendRedirect while redirecting within my application (That is what this forum is about - learning from each other ).It would be great to learn from you that in what situation you would want to have a new response ?? please elaborate. Thanks in advance.