Exemple : 

public ActionForward execute(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws Exception {

ArrayList students = new ArrayList ();

HttpSession session = request.getSession(); 

String target = new String ("success");

LoginForm loginForm = (LoginForm) form;

String userName = ((LoginForm) form).getUserName();

String userPassword = ((LoginForm) form).getUserPassword();

String user = getUser(userName, userPassword);

if (user == null) {

target = new String ("login");

ActionErrors errors = new ActionErrors ();

errors.add(ActionErrors.GLOBAL_ERROR, new ActionError (

"errors.userNotFound", userName)); 

saveErrors(request, errors) ;

}

else {

session.setAttribute("USER :", user);

} 

return (mapping.findForward(target));

}



And in your jsp view you will need to add 

a <html:errors /> tag.

Don't forget to add your message keys on your application.properties file.

Example :

userNameNotFound=<li>User name not found<li>

--

Alexandre Jaquet



----- Original Message ----- 
From: "julian green" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, February 28, 2003 2:38 PM
Subject: How do you display action error messages in jsp?


> I have a jsp page that is being pre-populated by the action, the action 
> is writing values directly into the form bean.  But I also want to 
> display error messages generated by the action.
> 
> I am doing a:
> 
>         saveErrors(request, errors);
> 
>         return mapping.findForward("success");
> 
> at the end of the action, but nothing ever shows up.  Any ideas?
> 
> The "success" forward mapps to the jsp page in struts-config.xml
> 
> Julian
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to