struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jasper Rosenberg (JIRA)" <j...@apache.org>
Subject [jira] Updated: (WW-1853) Extend HttpHeaderResult to support HttpServletResponse.sendError()
Date Fri, 23 Mar 2007 20:11:51 GMT

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

Jasper Rosenberg updated WW-1853:
---------------------------------

    Attachment: ErrorSupportingHttpHeaderResult.java

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


Mime
View raw message