Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: returning error from action page to jsp

Laurie Harper

2007-01-02

Replies:

Meenakshi j wrote:
> Hello,
>  Can someone tell me, in case a null value, how I can use ActionErrors to return an error to a jsp page and show a pop up to a user describing the error?

To send the error from your action:

  public String execute(
        HttpServletRequest request,
        HttpServletResponse response) {

     ...

     ActionErrors errors = new ActionErrors();
     errors.add(new ActionMessage("key");
     saveErrors(request, errors);

     ...
  }

In your JSP, you'd render it using the <html:errors> or (preferred)
<html:messages> tags. Use one of those to inject the error message into
your popup Javascript or HTML markup.

L.

[1] http://struts.apache.org/1.x/struts-taglib/tlddoc/html/errors.html
[2] http://struts.apache.org/1.x/struts-taglib/tlddoc/html/messages.html


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.