Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in displaying error in jsp page

 
Ahmed Shaikh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am using servlet and JSP in my application.
Problem is that :-
when a user try to login through login.jsp then this request goes to LoginAction servlet, where DB connection is done .
In this (LoginAction)server if user is not Authentic then it will through an "Invalid Login Attempt By user <userName>".
I want to display this error message on login.jsp.
plz help me in solving this problem.

Thanx in advance..
 
Sravan Kumar
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before redirecting to the JSP from LoginAction Servlet, set the userName in Session and authentication status in reuest as attributes and forward to JSP.

In JSP, You can check if the user is authenticated from the request attribute and display the message accordingly. The userName can alsways be retrieved from the Session.
 
Ahmed Shaikh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sravan ,
Thanx for your reply.
One thing is that I am already checking user Authentication in servlet then why I have to again check it in jsp.
I want to print(on login.jsp) that mesaage which is thrown by an InvalidLoginException class(in LoginAction servlet).
can I use a concept of errorpage.jsp.
Plz help me with example.
Thanx
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of using an error page, why not forward back to the login jsp?
Before doing so, bind an error message to request scope.
Then, in your JSP, you can display the message.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic