On Wed, 14 Mar 2001, Richard Yumul wrote:

> Is there a particular reason why the <logic:present> tag from the
> struts-logic taglib can't check if a value has been set in the request w/
> the Servlet.setAttribute() method?
> 
> It seems like this would be common design pattern:
> 
>       The Action class successfully processes some submitted form data,
> 
>       It adds some info to the request object
> (HttpServletRequest.setAttribute()),
>       (like a status message of the whatever the form was supposed to do)
> 
>       Passes control to whatever the mapping.findforward() method returns;
> 
>       Then the JSP displays the page with the status message w/ a
> request.getAttribute().
> 
> Essentially, I'd like to avoid a:
> 
> <%
>       String mesg = request.getAttribute("status.message");
>       if (mesg != null) {
>               out.println(mesg);
>       }
> %>
> 
> in my JSP page and leverage as much as I can from the taglibs.  Does struts
> provide any other mechanism to accomplish this?
> 

Doesn't this do what you want?

        <logic:present name="status.message" scope="request">
                <bean:write name="status.message"/>
        </logic:present>

Request attributes (in an Action) are the same as request scope beans (in
a JSP page).

> 
> Thanks,
> Rich
> 

Craig McClanahan

Reply via email to