<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>RE: DownloadAction is struts portlet.</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=2082281" />
  <subtitle>RE: DownloadAction is struts portlet.</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=2082281</id>
  <updated>2026-04-07T04:54:11Z</updated>
  <dc:date>2026-04-07T04:54:11Z</dc:date>
  <entry>
    <title>RE: DownloadAction is struts portlet.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=2476035" />
    <author>
      <name>Minhchau Dang</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=2476035</id>
    <updated>2009-03-12T22:14:03Z</updated>
    <published>2009-03-12T22:14:03Z</published>
    <summary type="html">&lt;div class="quote-title"&gt;Vivek N Kapse:&lt;/div&gt;&lt;blockquote&gt;Hi Dang,&lt;br /&gt;&lt;br /&gt;The excel file is shown in the pop-up window as text with junk characters.&lt;/blockquote&gt;&lt;br /&gt;This is behavior I would expect if the Content-Disposition header was not properly set.  Use Firefox with LiveHttpHeaders and make sure that you see the Content-Disposition header set to &amp;#39;attachment&amp;#39;.  Also make sure that both &amp;#34;Content-Disposition&amp;#34; and &amp;#34;attachment&amp;#34; are spelled correctly.&lt;br /&gt;&lt;br /&gt;If you do not see a Content-Disposition header at all (or you see two of them -- one specifying &amp;#39;inline&amp;#39; and the other specifying &amp;#39;attachment&amp;#39;), it&amp;#39;s very possible that the Struts DownloadAction is not compatible with either Liferay or the Struts portlet bridge.&lt;br /&gt;&lt;br /&gt;Ray Augé wrote a very detailed &lt;a href="http://www.liferay.com/web/rauge/blog/-/blogs/%5Bhowto%5D-dowloading-files-from-a-portlet"&gt;HOWTO&lt;/a&gt; describing ways to deliver files from a portlet, depending on which version of Liferay you are trying to use.  I recommend trying one of those techniques to deliver your file, in the event that the Struts DownloadAction is not providing you with the desired behavior.</summary>
    <dc:creator>Minhchau Dang</dc:creator>
    <dc:date>2009-03-12T22:14:03Z</dc:date>
  </entry>
  <entry>
    <title>RE: DownloadAction is struts portlet.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=2473110" />
    <author>
      <name>Vivek N Kapse</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=2473110</id>
    <updated>2009-03-12T17:55:24Z</updated>
    <published>2009-03-12T17:55:24Z</published>
    <summary type="html">Hi Dang,&lt;br /&gt;&lt;br /&gt;Thanks for you response. I did try as u suggested but the result is still the same. The excel file is shown in the pop-up window as text with junk characters. Is there anything else you can suggest. &lt;br /&gt;Do you think there&amp;#39;s something wrong in the way I submit my form to generate the excel report? Here is the submit Function &lt;br /&gt;&lt;br /&gt;function submitReport() {&lt;br /&gt;var resultWindow = window.open(&amp;#39;&amp;lt;portlet:actionURL windowState=&amp;#34;&amp;lt;%= LiferayWindowState.EXCLUSIVE.toString() %&amp;gt;&amp;#34;&amp;gt;&lt;br /&gt;&lt;strong&gt;&amp;lt;portlet:param name=&amp;#34;_spage&amp;#34; value=&amp;#34;/portlet_action/Reporting_portlet/Reporting/DownloadMyReport&amp;#34;/&amp;gt;&amp;#34;/&amp;gt;&lt;/strong&gt;&lt;br /&gt;&amp;lt;/portlet:actionURL&amp;gt;&amp;#39;);&lt;br /&gt;resultWindow .opener = window;&lt;br /&gt;resultWindow .focus();&lt;br /&gt;}</summary>
    <dc:creator>Vivek N Kapse</dc:creator>
    <dc:date>2009-03-12T17:55:24Z</dc:date>
  </entry>
  <entry>
    <title>RE: DownloadAction is struts portlet.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=2404608" />
    <author>
      <name>Minhchau Dang</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=2404608</id>
    <updated>2009-03-05T23:58:56Z</updated>
    <published>2009-03-05T23:58:56Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;From the &lt;a href="http://wiki.apache.org/struts/StrutsFileDownload#head-54368bb2778429bd6d32b4ea42b2a15ca111f19a"&gt;Struts Wiki&lt;/a&gt;:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;response.setHeader(
	"Content-Disposition",
	"attachment; filename=" + expFile.getName());

return new DownloadAction.FileStreamInfo(contentType, expFile);&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Minhchau Dang</dc:creator>
    <dc:date>2009-03-05T23:58:56Z</dc:date>
  </entry>
  <entry>
    <title>RE: DownloadAction is struts portlet.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=2404019" />
    <author>
      <name>Vivek N Kapse</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=2404019</id>
    <updated>2009-03-05T22:19:35Z</updated>
    <published>2009-03-05T22:19:35Z</published>
    <summary type="html">I still haven&amp;#39;t resolved this issue. It&amp;#39;s been long I have posted this thread and no inputs yet. Please, if anyone has any inputs, will be glad to try them out.</summary>
    <dc:creator>Vivek N Kapse</dc:creator>
    <dc:date>2009-03-05T22:19:35Z</dc:date>
  </entry>
  <entry>
    <title>RE: DownloadAction is struts portlet.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=2147426" />
    <author>
      <name>Vivek N Kapse</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=2147426</id>
    <updated>2009-02-10T19:25:44Z</updated>
    <published>2009-02-10T19:25:44Z</published>
    <summary type="html">I have written an Action class that extends DownloadAction and this writes my report into a spreadsheet (.xls file). This action successfully writes my report into an excelsheet at the path specified but instead of showing &amp;#39;File Download&amp;#39; pop-up window with &amp;#34;Do you want to open or save this file?&amp;#34; option it renders the .xls file as text with lot of junk characters. Not able to figure out why its rendering it as text with junk. I have even set the content-type in DownloadAction class to application/vnd.ms-excel(check below). I also see that the file is successfully written into the path specified.&lt;br /&gt;&lt;strong&gt;I have also added &amp;lt;mime-mapping&amp;gt; tag in my web.xml file.&lt;/strong&gt;&lt;br /&gt;Here is how my action class looks&lt;br /&gt;**************************************************************************************************&lt;br /&gt;DownloadMyReport.java&lt;br /&gt;**************************************************************************************************&lt;br /&gt;public class DownloadMyReport extends DownloadAction {&lt;br /&gt;protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,&lt;br /&gt;HttpServletRequest request,&lt;br /&gt;HttpServletResponse response) {&lt;br /&gt;String contentType = &amp;#34;application/vnd.ms-excel&amp;#34;;&lt;br /&gt;String Fname = (String) ReportBean.get(&amp;#34;Fname&amp;#34;);&lt;br /&gt;String Lname = (String) ReportBean.get(&amp;#34;Lname&amp;#34;);&lt;br /&gt;.&lt;br /&gt;expFile = new File(&amp;#34;C:\\Reporta\\MyReport.xls&amp;#34;);&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;return new DownloadAction.FileStreamInfo(contentType, expFile);&lt;br /&gt;} &lt;br /&gt;*****************************************************************************************************&lt;br /&gt;Web.xml&lt;br /&gt;*****************************************************************************************************&lt;br /&gt;    &amp;lt;mime-mapping&amp;gt;&lt;br /&gt;        &amp;lt;extension&amp;gt;xls&amp;lt;/extension&amp;gt;&lt;br /&gt;        &amp;lt;mime-type&amp;gt;application/vnd.ms-excel&amp;lt;/mime-type&amp;gt;&lt;br /&gt;    &amp;lt;/mime-mapping&amp;gt; &lt;br /&gt;******************************************************************************************************&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;********************************************************************************************************&lt;br /&gt;InputForm.jsp&lt;br /&gt;*********************************************************************************************************&lt;br /&gt;&amp;lt;form name=&amp;#34;myReport&amp;#34; action=&amp;#34;&amp;#34; method=&amp;#34;post&amp;#34;&amp;gt;&lt;br /&gt;&amp;lt;input type=&amp;#34;text&amp;#34; name=&amp;#34;Fname&amp;#34;&amp;gt;&lt;br /&gt;&amp;lt;input type=&amp;#34;text&amp;#34; name=&amp;#34;Lname&amp;#34;&amp;gt;&lt;br /&gt;&amp;lt;a href=&amp;#34;#&amp;#34; onclick=&amp;#34;submitReport()&amp;#34;&amp;gt;Submit Report&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;script type=&amp;#34;text/javascript&amp;#34;&amp;gt;&lt;br /&gt;function submitReport() {&lt;br /&gt;var resultWindow = window.open(&amp;#39;&amp;lt;portlet:actionURL windowState=&amp;#34;&amp;lt;%= LiferayWindowState.EXCLUSIVE.toString() %&amp;gt;&amp;#34;&amp;gt;&lt;br /&gt;&amp;lt;portlet:param name=&amp;#34;_spage&amp;#34; value=&amp;#34;/portlet_action/Reporting_portlet/Reporting/DownloadMyReport&amp;#34;/&amp;gt;&amp;#34;/&amp;gt;&lt;br /&gt;&amp;lt;/portlet:actionURL&amp;gt;&amp;#39;);&lt;br /&gt;resultWindow .opener = window;&lt;br /&gt;resultWindow .focus();&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;*********************************************************************************************************&lt;br /&gt;struts-config.xml&lt;br /&gt;*********************************************************************************************************&lt;br /&gt;&amp;lt;form-beans&amp;gt;&lt;br /&gt;&amp;lt;form-bean name=&amp;#34;ReportBean&amp;#34; type=&amp;#34;org.apache.struts.validator.DynaValidatorForm&amp;#34;&amp;gt;&lt;br /&gt;&amp;lt;form-property name=&amp;#34;Fname&amp;#34; type=&amp;#34;java.lang.String&amp;#34;/&amp;gt;&lt;br /&gt;&amp;lt;form-property name=&amp;#34;Lname&amp;#34; type=&amp;#34;java.lang.String&amp;#34;/&amp;gt;&lt;br /&gt;&amp;lt;/form-bean&amp;gt;&lt;br /&gt;&amp;lt;action path=&amp;#34;/Reporting_portlet/Reporting/DownloadMyReport&amp;#34;&lt;br /&gt;type=&amp;#34;com.reporting.MyReport&amp;#34; name=&amp;#34;ReportBean&amp;#34; scope=&amp;#34;session&amp;#34; validate=&amp;#34;true&amp;#34;&lt;br /&gt;input=&amp;#34;portlet.Reporting_portlet.ReportRequest&amp;#34;/&amp;gt;&lt;br /&gt;**********************************************************************************************************</summary>
    <dc:creator>Vivek N Kapse</dc:creator>
    <dc:date>2009-02-10T19:25:44Z</dc:date>
  </entry>
</feed>
