• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

how to send error messages from sendRedirect to Jsp from a servlet

 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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.

Is it possible to do this by sendRedirect?

Can some one please advice me on this?

Thanks in advance!
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://coderanch.com/t/451830/JSP/java/show-validation-error-messages-jsp
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Moieen Khatri
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Prashant,

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!!
 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are most welcomed.
Good that this worked for you.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prashant Hurria wrote:Why are you using sendRedirect.Send redirect is normally used when you need to redirect the user to somewhere outside your application.


Not generally true.

Redirects are use liberally within the same web application when its appropriate to generate a new response.
 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:
Not generally true.

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.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prashant Hurria wrote:It would be great to learn from you that in what situation you would want to have a new response ?? please elaborate.



Redirect is used in PRG-pattern
 
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic