After some googling; I'm looking at the Result interface. Would it be proper for the action to set a property, and use this custom Result to read that property from ValueStack and write it to (with XStream for isntance) ServletActionContext.getResponse().getOutputStream() ?
So Results exist for doing this for XML and/or JSON? It seems like it would be re-occurring situation, espectially with ajax? I'm just getting into Struts2; I'm looking to see if I'm doing things as they ought to be done. Best practices, etc. gove...@students.kennesaw.edu On Wed, Oct 13, 2010 at 1:02 AM, Li Ying <liying.cn.2...@gmail.com> wrote: > You can generate your XML dynamically, and then write it to the response > stream. > If you set the response headers correctly, the browser should treat > this response as a file downloading. > > Code in your action looks like this: > > public String execute() { > String xmlStr = generateXML(); > > HttpServletResponse response = ServletActionContext.getResponse(); > > response.setContentType("text/xml"); > > response.setHeader("Content-Disposition", > "attachment; filename=" + yourXmlFileName); > > OutputStream out = response.getOutputStream(); > > out.write(xmlStr.getBytes("UTF-8")); > > out.close(); > > return null; // this make sure the page not to jump > } > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >