You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Don Brown (JIRA)" <ji...@apache.org> on 2007/05/19 07:19:42 UTC

[jira] Updated: (WW-1853) Extend HttpHeaderResult to support HttpServletResponse.sendError()

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

Don Brown updated WW-1853:
--------------------------

    Fix Version/s:     (was: 2.0.8)
                   2.1.0

Moving to 2.1.0 as it is a new feature (like the idea though, and if someone wants to backport it, please do)

> 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
>             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.