You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Graham Leggett <mi...@sharp.fm> on 2009/11/04 22:25:42 UTC

Returning a specific status code (404, 500, etc) from an Action

Hi all,

I am currently trying to find out whether a struts2 action can return a
specific response code (eg 404, or 500).

Is this possible?

Regards,
Graham
--

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Returning a specific status code (404, 500, etc) from an Action

Posted by Chris Pratt <th...@gmail.com>.
Yup, just define your result to use the httpheader type.  Like so,

      <result name="failure" type="httpheader">404</result>

(*Chris*)


On Wed, Nov 4, 2009 at 1:25 PM, Graham Leggett <mi...@sharp.fm> wrote:

> Hi all,
>
> I am currently trying to find out whether a struts2 action can return a
> specific response code (eg 404, or 500).
>
> Is this possible?
>
> Regards,
> Graham
> --
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Returning a specific status code (404, 500, etc) from an Action

Posted by Chris Pratt <th...@gmail.com>.
There's some info in the wiki, like there is for all the standard results (
http://cwiki.apache.org/WW/httpheader-result.html)
  (*Chris*)

On Wed, Nov 4, 2009 at 1:49 PM, Graham Leggett <mi...@sharp.fm> wrote:

> Dale Newfield wrote:
>
> >> I am currently trying to find out whether a struts2 action can return a
> >> specific response code (eg 404, or 500).
> >
> > Check out the httpheader result type.
>
> Does any documentation exist anywhere for this?
>
> After a whole lot of googling for httpheader, I eventually came across
> an example:
>
> @Result(name="success", type="httpheader", params={"status", "500",
> "errorMessage", "Internal Error"})
>
>
> http://www.techq.com/source/code/Struts/2.1.6/docs/docs/convention-plugin.html#ConventionPlugin-Resultannotation
>
> I am looking for a reference of some kind for it, does such a thing exist?
>
> Regards,
> Graham
> --
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Returning a specific status code (404, 500, etc) from an Action

Posted by Dale Newfield <da...@newfield.org>.
Graham Leggett wrote:
> Dale Newfield wrote:
>> Check out the httpheader result type.
> 
> Does any documentation exist anywhere for this?

At least:
http://struts.apache.org/2.1.8/struts2-core/apidocs/org/apache/struts2/dispatcher/HttpHeaderResult.html

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Returning a specific status code (404, 500, etc) from an Action

Posted by Graham Leggett <mi...@sharp.fm>.
Dale Newfield wrote:

>> I am currently trying to find out whether a struts2 action can return a
>> specific response code (eg 404, or 500).
> 
> Check out the httpheader result type.

Does any documentation exist anywhere for this?

After a whole lot of googling for httpheader, I eventually came across
an example:

@Result(name="success", type="httpheader", params={"status", "500",
"errorMessage", "Internal Error"})

http://www.techq.com/source/code/Struts/2.1.6/docs/docs/convention-plugin.html#ConventionPlugin-Resultannotation

I am looking for a reference of some kind for it, does such a thing exist?

Regards,
Graham
--

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Returning a specific status code (404, 500, etc) from an Action

Posted by Dale Newfield <da...@newfield.org>.
Graham Leggett wrote:
> I am currently trying to find out whether a struts2 action can return a
> specific response code (eg 404, or 500).

Check out the httpheader result type.

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org