You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Cartwright <Jo...@noaa.gov> on 2007/08/24 23:19:11 UTC

[S2] raw XML response

Hello All,

I'd like to simply return some text from a Action w/o redirecting to a 
page. I did this sort of thing in Struts1 by using the response's 
PrintWriter and returning null from the Action's execute method.

 From the documentation, I'd expected that a return type of "xslt" w/o 
the stylesheetLocation parameter would have done the trick, but I'm 
getting a "javax.xml.transform.TransformerException: Operation not 
supported. - [unknown location]" exception.

If I was to use the plaintext resulttype and uses the 
HttpServletResponse's PrintWriter to write out my  text, I suppose I 
could also setContentType on the response.  Just seems like I'm going 
about this the wrong way.

Could someone please help me out?

Thanks!

-- john

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


Re: [S2] raw XML response

Posted by Chris Pratt <th...@gmail.com>.
I don't specify anything at all, here's one of my actions:

    <action name="user-add" class="com.company.controller.UserAddAction"/>

  (*Chris*)


On 8/28/07, John Cartwright <Jo...@noaa.gov> wrote:
> Thanks for your reply Chris.  Are you specifying a result type of
> "plaintext" in struts.xml or any <result> element at all?  I seem to be
> running into a situation where struts2 is trying to redirect me to a JSP
> w/ the same name as the action.
>
> Thanks again for your help!
>
> -- john
>
>
> Chris Pratt wrote:
> >> I'd like to simply return some text from a Action w/o redirecting to a
> >> page. I did this sort of thing in Struts1 by using the response's
> >> PrintWriter and returning null from the Action's execute method.
> >>
> >
> > You can do it exactly the way you did in Struts 1 (or mostly anyway).
> > If you implement ServletResponseAware you'll have access to the
> > HttpServletResponse and if you return null from the action the system
> > won't forward you anywhere.  I have several AJAX Actions that do
> > exactly this.
> >   (*Chris*)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: [S2] raw XML response

Posted by John Cartwright <Jo...@noaa.gov>.
Thanks for your reply Chris.  Are you specifying a result type of 
"plaintext" in struts.xml or any <result> element at all?  I seem to be 
running into a situation where struts2 is trying to redirect me to a JSP 
w/ the same name as the action.

Thanks again for your help!

-- john


Chris Pratt wrote:
>> I'd like to simply return some text from a Action w/o redirecting to a
>> page. I did this sort of thing in Struts1 by using the response's
>> PrintWriter and returning null from the Action's execute method.
>>     
>
> You can do it exactly the way you did in Struts 1 (or mostly anyway).
> If you implement ServletResponseAware you'll have access to the
> HttpServletResponse and if you return null from the action the system
> won't forward you anywhere.  I have several AJAX Actions that do
> exactly this.
>   (*Chris*)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   

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


Re: [S2] raw XML response

Posted by Chris Pratt <th...@gmail.com>.
> I'd like to simply return some text from a Action w/o redirecting to a
> page. I did this sort of thing in Struts1 by using the response's
> PrintWriter and returning null from the Action's execute method.

You can do it exactly the way you did in Struts 1 (or mostly anyway).
If you implement ServletResponseAware you'll have access to the
HttpServletResponse and if you return null from the action the system
won't forward you anywhere.  I have several AJAX Actions that do
exactly this.
  (*Chris*)

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