I want   a struts action class to download xml file .I
 do not want to use Struts DownloadAction because I
have a  super class  called AbstractActionBase  which
extends to  struts action class and all my action
classes extends to this AbstractActionBase. 

For downloading a file I am using normal struts action
class rather than DownloadAction class (I do not want
to use struts DownloadAction).
This normal struts action class returns null instead
of ActionForward  and sets the response content type
and writes to reponse output stream . My question is
is this proper way to    write a download Action  in
struts  without using struts DownloadAction class .


Here is the code fo my download action class 

    public ActionForward performAction(
        ActionMapping mapping, ActionForm form,
HttpServletRequest request,
        HttpServletResponse response) throws Exception
{

        ResultsForm resultsForm = (ResultsForm)
request.getSession().getAttribute("resultsForm");
        FMCDataDocument fmcDataDocument =
resultsForm.getIdFlagFmcDataDocument();
        byte[] bytearray =
fmcDataDocument.xmlText().getBytes();
       
response.setContentType("application/rss+xml");
        response.setContentLength(bytearray.length);
        response.setHeader("Content-Disposition",
"attachment;filename=sample.xml");
        response.getOutputStream().write(bytearray);
        return null;
    }


thanks & regards



                
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to