Results 1 to 5 of 5
  1. #1
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default Send error message from servlet to jsp

    Hey,

    I'm quite new to Java EE and servlets so how do I send a error message to a jsp page?

    scenario:

    Some one insert his/her's username or password wrong, by displaying the error message on the validation servlet I would like to send a message back to the jsp login page and display the message there.

    I would be very greatful if someone would help me :)

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,123
    Rep Power
    20

    Default

    On a failed login you generally forward back to the login.jsp, but add some form of error message/object/whatever attribute to the request. The login.jsp will have a bit of code somewhere that checks if this attribute exists on the request, if so it then displays it.

  3. #3
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Yes, I know that, but how to I do it? In php I redirected back to the login page with a uri segment and on the login page I checked if that segment exists, if so then gave a error message.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,123
    Rep Power
    20

    Default

    I just said how you do it.
    Add an attribute to the request (the HttpRequest object), then forward (not redirect) back to the login page. Presumably you already forward to a success page on success...so just do that, but to the login.

    If you don't know how to forward, or how to add attributes to the request, or how to work with attributes in a JSP page then you'll need to read up on that.

  5. #5
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

Similar Threads

  1. Help with servlet error message
    By ricky_40 in forum New To Java
    Replies: 1
    Last Post: 03-08-2010, 07:01 AM
  2. how to send values from servlet..
    By hussainzim in forum Java Servlet
    Replies: 1
    Last Post: 08-06-2008, 08:28 AM
  3. Replies: 1
    Last Post: 01-28-2008, 11:49 AM
  4. Replies: 0
    Last Post: 01-27-2008, 09:17 PM
  5. error message on jsp
    By sandor in forum Web Frameworks
    Replies: 1
    Last Post: 04-11-2007, 03:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •