You could use StreamResult:

<package name="test" namespace="/test" extends="struts-default">
        <action name="stream" class="it.xxx.StreamAction">
            <result type="stream">
                <param name="contentType">${mimeType}</param>
                <param name="contentLength">${length}</param>
                <param name="contentDisposition">inline;
filename="${fileName}"</param>
                <param name="inputName">inputStream</param>
                <param name="bufferSize">1024</param>
                <param name="allowCaching">false</param>
            </result>
        </action>
    </package>


public class StreamAction  {
    private String fileName;
    private int buffSize = 1024;
    private BufferedInputStream fileStream;
    private long length;

    public String execute() throws Exception {
        File f = new File(fileName);
        FileInputStream fis = new FileInputStream(f);
        length=f.length();
        fileStream = new BufferedInputStream(fis, buffSize);
        return Action.SUCCESS;
    }

    public InputStream getInputStream() {
        return fileStream;
    }

    public String getMimeType() {
        return "application/x-pdf";
    }

    public long getLength() {
        return length;
    }

    public String getFileName() {
        return fileName;
    }

    public int getBuffSize() {
        return buffSize;
    }

  }

--
Maurizio Cucchiara

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

Reply via email to