• 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

Login - revisited

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a Struts newbie attempting to write a login app.

Most (if not all) of the examples I have found online use three JSP pages:

login.jsp (prompts user for username/password, re-displays if invalid)
fail.jsp (username/password valid but incorrect)
success.jsp (username/password was correct)



I would like to change my app to have use only two JSP pages:

login.jsp (prompts user for username/password, re-displays if invalid, re-displays if incorrect)
success.jsp (username/password was correct)

I have an Action which validates user input and, if valid, invokes a bean to authenticate the user.

I presume I need three findForwards in my Action:
return (mapping.findForward(this.FORWARD_invalid));
return (mapping.findForward(this.FORWARD_incorrect));
return (mapping.findForward(this.FORWARD_success));

How do I let the login.jsp page know which error condition to display ("invalid field", "could not authenticate", or no error)?

Am I on the right track?
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If user fails authentication, add an ActionError/ActionMessage from the Action and then forward the user to the input forward.

Then in your login.jsp make sure to have the html:errors/messages tag to display the error.
 
David Pizon
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"add an ActionError/ActionMessage from the Action"

Right... how do I do that?

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception;

I want to keep authentication in the LoginAction separate from validation in the LoginForm. Can I stuff an ActionErrors() object in an ActionForward() object?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic