IE6 displays the image inline because it recognises the extension of the file in preference to the mime type.

The stream result allows you to set the Content-Disposition header, as you have already done in your JSP code.

<param name="contentDisposition">attachment; filename=${fileName}</param>

This disposition will ensure the file is downloaded as file (almost) irrespective of the mime type. If you provide a getFileName() property in your action the notation ${fileName} will read it (this is allowed in struts.xml). Otherwise you can simple hardcode the filename to something useful.

The exception you quoted is unrelated and caused because you're writing to the output stream within a JSP that's already doing so. That code is better suited to its own servlet.

Hope that helps,
regards,
Jeromy Evans

Joe Lam wrote:
try to make a file download action without opening the file.
I try the showcase file download example. change contentType to
application/x-download in struts.xml

&lt;param name="contentType"&gt;application/x-download&lt;/param&gt;

with firefox it works fine. with IE, it still open the gif in browser.

anyone could help? the stream result type is handy. don't think i should re
invent the wheel.

btw just for curious I try to stream the file by jsp. I do something like
this in jsp:

    stream=response.getOutputStream();
    response.setContentType("application/x-download");
    response.addHeader("Content-Disposition","attachment;
filename="+filename);
    response.setContentLength( (int) f.length());
    blah blah blah to write data to stream

both IE and firefox are able to get the download dialog box but there is
exception in log file

ERROR [lina.core.StandardWrapperValve: 250] Servlet.service() for servlet
default threw exception
java.lang.IllegalStateException: getOutputStream() has already been called
for this response


I think stream result type should be the best solution. but I cant make IE
to download the file. Any help? Thank you very much

Joe


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

Reply via email to