Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Trouble with attributes and redirect

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Login.jsp in which I have a form for the user to submit his username and password.
This form is sent to a servlet that processes the login information. If correct, it goes to welcome.jsp. If incorrect, it comes back to Login.jsp giving the user an error message and allowing him to re-enter his username and password.
In my servlet, I use-
request.setAttribute("incorrectLogin", "Incorrect Login.");
res.sendRedirect("login.jsp");
In my JSP, the Java code is-
<%
if( ((String)(request.getAttribute("incorrectLogin"))) != null )
{
String inCorMess = "Incorrect username or password. Please try again.";
out.println("p align=center>" + inCorMess + "<p>");
}
%>
I do return to login.jsp but no message is displayed. How do I correct this?
Have spent too much time and have found no answer.
[ April 20, 2004: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67637
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
When you redirect, a new request is generated by the browser and attributes that you have placed on the old request are not available.
You should explore using a forward rather than a redirect.
P.S. I also edited your subject to be more descriptive -- please be sure to make your subject lines more decriptive in future posts.
 
Oh, sure, you could do that. Or you could eat some pie. While reading this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic