This is my action method containing the business logic. I want to show error message from this action method in the jsp. The control goes to the jsp but the error message does not show up.In my jsp i have this code to display error message:
<html:errors/>
I am new to struts. Also in eclipse it says that saveErrors
method is deprecated. i know how to display errors using validate method of the bean class which extends ActionForm
.
public ActionForward upload(....)
{
if(noOfColumns>7)
{
errors.add(ActionErrors.GLOBAL_ERROR, new ActionMessage("error.file.maxCols"));
saveErrors(request,errors);
return mapping.findForward("uploadVIPProcess");
}
}
finally found it. This was very simple:
public ActionForward upload(....)
{
errors.add(ActionErrors.GLOBAL_ERROR, new ActionMessage("error.file.maxCols"));
saveErrors(request,errors);
return (new ActionForward(mapping.getInput()));
}
so the only difference is instead of:
return mapping.findForward("uploadVIPProcess");
I changed it to:
return (new ActionForward(mapping.getInput()));
and it's working just fine:)