[ 
https://issues.apache.org/struts/browse/WW-1853?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Musachy Barroso resolved WW-1853.
---------------------------------

    Resolution: Fixed

Thanks for the patch. I added it to HttpHeaderResult, although the error code 
is not technically a header, I think it makes sense to have this functionality 
in HttpHeaderResult,.

> Extend HttpHeaderResult to support HttpServletResponse.sendError()
> ------------------------------------------------------------------
>
>                 Key: WW-1853
>                 URL: https://issues.apache.org/struts/browse/WW-1853
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Dispatch
>    Affects Versions: 2.0.6, 2.0.7
>            Reporter: Jasper Rosenberg
>            Assignee: Musachy Barroso
>             Fix For: 2.1.0
>
>         Attachments: ErrorSupportingHttpHeaderResult.java
>
>
> I had a need to have an action return a 404.  To do this, I extended the 
> HttpHeaderResult class to accept an optional "errorCode" parameter which, if 
> present, would trigger a response.sendError(errorCode).
> Attached is my extension, but it probably should either be broken into its 
> own result class, or properly merged into HttpHeaderResult itself.  Also, 
> support should probably be added for an optional "errorMessage" so 
> response.sendError(errorCode, errorMessage) can be invoked instead if an 
> error message is available.
> Here is a sample usage:
>     <package name="default" extends="struts-default">
>          <result-types>
>              <result-type name="httperror" 
> class="com.mycompany.struts2.result.ErrorSupportingHttpHeaderResult"/>
>          </result-types>
>         <global-results>
>             <!-- 404 page result: not found. -->
>             <result name="404" type="httperror">
>               <param name="errorCode">404</param>
>             </result>
>         </global-results>
>     </package>
> Now I can have any action return "404" as the result and I will get a 404 
> page.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to