• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in displaying error in jsp page

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic