You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Craig R. McClanahan" <cr...@apache.org> on 2001/06/02 08:09:39 UTC

Re: setContentType() for xml output


On Thu, 31 May 2001, Wu, Ying (LNG-CIS) wrote:

> I need to send a string which represents a xml file to browser, I need to
> call response.setContentType("text/xml").  But it is at ActionServlet level
> and is default to "text/html".
> 
> 1. Any idea?

Although the controller servlet sets the default output type, this gets
replaced if you forward to a JSP page (or whatever) at the end of your
action.

> 2. I can do the output at MyAction.perform() level, but how to handle the
> return type of this method?
> 

If you are generating the output in your Action itself, you should return
null from your perform() method.  This tells the controller servlet that
the response has already been created, so no forwarding is required.

> Thanks.
> 
> Ying
> 

Craig