internet explorer - Struts2 StreamResult not working in IE8 -
i'm trying allow downloading of pdfs located on file system. have action class downloadfileaction extends actionsupport following:
public string execute() { // lookup file inputstream = new fileinputstream(file); return success; } public string getcontenttype() { return "application/pdf"; } public string getcontentdisposition() { return "attachment;filename=\"filename.pdf\""; } my action mapping defined you'd expect:
<action name="downloadfile" class="com.foo.downloadfileaction"> <result name="success" type="stream"> <param name="allowcaching">false</param> </result> </action> this works great in firefox , ie9, fails work in ie8 unknown reasons. thoughts?
update: using live http headers plugin, see when doing download in firefox. assume same in ie8:
http://fmpdmb:7001/shopping/search/printitemdetail.action?upid=41271812&oet2rtjy=lij8hdlqt7igptdozbz5ocig /shopping/search/printitemdetail.action?upid=41271812&oet2rtjy=lij8hdlqt7igptdozbz5ocig http/1.1 host: fmpdmb:7001 user-agent: mozilla/5.0 (x11; ubuntu; linux x86_64; rv:13.0) gecko/20100101 firefox/13.0.1 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-us,en;q=0.5 accept-encoding: gzip, deflate connection: keep-alive referer: http://fmpdmb:7001/shopping/search/searchresultitemdetail.action?upid=41271812 cookie: adminconsolesession=vqpcpk2n58p1qztlrpvhywjvs9pdmt2b60pdrpqhrbhqhjgblmhv!-1356202776; emall-session=r7fbprmcq1dvqt1wkf214nznpt61l03jhhn1d7z8tzzh5tzcxvdm!1350268378 http/1.1 200 ok cache-control: no-cache date: wed, 27 jun 2012 15:48:00 gmt pragma: nocache, no-cache transfer-encoding: chunked content-type: application/pdf expires: 0 content-disposition: inline;filename="document.pdf" x-powered-by: servlet/2.5 jsp/2.1 update: bit more info. think may have fact app running under https. help?
the action should this:
<action name="download" class="com.project.downloadaction"> <result name="success" type="stream"> <param name="contenttype">application/pdf</param> <param name="inputname">inputstream</param> <param name="contentdisposition">attachment;filename="download.pdf"</param> <param name="buffersize">1024</param> </result> </action> update
check out article: internet explorer cannot download https://something. if using https , prevent caching, download fail.
try define prevent error:
cache-control: private, max-age=15
Comments
Post a Comment