<?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>Issue with  serveResource</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112454773" />
  <subtitle>Issue with  serveResource</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112454773</id>
  <updated>2026-04-06T04:05:02Z</updated>
  <dc:date>2026-04-06T04:05:02Z</dc:date>
  <entry>
    <title>RE: Issue with  serveResource</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112587295" />
    <author>
      <name>Daniel G</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112587295</id>
    <updated>2019-03-05T16:44:01Z</updated>
    <published>2019-03-05T16:44:01Z</published>
    <summary type="html">Hi all.&lt;br /&gt;&lt;br /&gt;First of all, thanks to both of you. I was able to solve the problem with your help.&lt;br /&gt;&lt;br /&gt;My issue was due to that I was calling the method in a wrong way, so the resource stand stuck in the server.&lt;br /&gt;&lt;br /&gt;Thanks again!&lt;br /&gt;&lt;br /&gt;regards</summary>
    <dc:creator>Daniel G</dc:creator>
    <dc:date>2019-03-05T16:44:01Z</dc:date>
  </entry>
  <entry>
    <title>RE: Issue with  serveResource</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112458298" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112458298</id>
    <updated>2019-02-25T14:44:02Z</updated>
    <published>2019-02-25T14:44:02Z</published>
    <summary type="html">Hi Daniel,&lt;br /&gt;&lt;br /&gt;Your serveResource method should take care of regenerating the file whenever it&amp;#39;s called. Is it? Not sure, from the code you posted... For that it normally would get some parameters from the caller page, so that the file would be correctly generated.&lt;br /&gt;&lt;br /&gt;HTH&lt;br /&gt;&lt;br /&gt;Fernando</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2019-02-25T14:44:02Z</dc:date>
  </entry>
  <entry>
    <title>RE: Issue with  serveResource</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112457601" />
    <author>
      <name>Jorge Diaz</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112457601</id>
    <updated>2019-02-25T14:04:58Z</updated>
    <published>2019-02-25T14:04:58Z</published>
    <summary type="html">Hi Daniel G,&lt;br /&gt;&lt;br /&gt;I implemented that funcionality in following portlet:&lt;ul style="list-style: disc outside;"&gt;&lt;li&gt;&lt;strong&gt;serveResource of portlet,&lt;/strong&gt; See lines 1226 to 1239:&lt;strong&gt; &lt;/strong&gt;&lt;a href="https://github.com/jorgediaz-lr/index-checker/blob/master/docroot/WEB-INF/src/jorgediazest/indexchecker/portlet/IndexCheckerPortlet.java#L1226-L1239"&gt;https://github.com/jorgediaz-lr/index-checker/blob/master/docroot/WEB-INF/src/jorgediazest/indexchecker/portlet/IndexCheckerPortlet.java#L1226-L1239&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;OutputUtils.servePortletFileEntry,&lt;/strong&gt; see lines 369 to 404:&lt;strong&gt; &lt;/strong&gt;&lt;a href="https://github.com/jorgediaz-lr/output-utils/blob/master/src/jorgediazest/util/output/OutputUtils.java#L369-L404"&gt;https://github.com/jorgediaz-lr/output-utils/blob/master/src/jorgediazest/util/output/OutputUtils.java#L369-L404&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;strong&gt;Notes:&lt;/strong&gt;&lt;br /&gt; &lt;ol style="list-style: decimal outside;" start="1"&gt;&lt;li&gt;serveResource  of portlet calls OutputUtils.servePortletFileEntry method &lt;/li&gt;&lt;li&gt;In order to have a resourceId in &lt;strong&gt;request.getResourceId()&lt;/strong&gt; call, you have to set it in the request during previous &lt;strong&gt;doView() &lt;/strong&gt;execution, see lines 443 to 450:&lt;br /&gt;&lt;ul style="list-style: disc outside;"&gt;&lt;li&gt;&lt;a href=""&gt;https://github.com/jorgediaz-lr/index-checker/blob/7ab8ba82c4882d2e2f808318d9201bafb37a4ebb/docroot/WEB-INF/src/jorgediazest/indexchecker/portlet/IndexCheckerPortlet.java#L443-L450&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Download link is written here, see lines 240 to 250:&lt;br /&gt;&lt;ul style="list-style: disc outside;"&gt;&lt;li&gt;&lt;a href="https://github.com/jorgediaz-lr/index-checker/blob/7ab8ba82c4882d2e2f808318d9201bafb37a4ebb/docroot/html/indexchecker/view.jsp#L240-L250"&gt;https://github.com/jorgediaz-lr/index-checker/blob/7ab8ba82c4882d2e2f808318d9201bafb37a4ebb/docroot/html/indexchecker/view.jsp#L240-L250&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;In my portlet I am generating all data in &lt;strong&gt;doView &lt;/strong&gt;method, storing it to document library and in &lt;strong&gt;serveResource &lt;/strong&gt;method I am just getting it and sending to browser, but it could be possible to do all generation code inside &lt;strong&gt;serveResource&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;Regards,&lt;br /&gt;Jorge&lt;strong&gt;&lt;/strong&gt;</summary>
    <dc:creator>Jorge Diaz</dc:creator>
    <dc:date>2019-02-25T14:04:58Z</dc:date>
  </entry>
  <entry>
    <title>Issue with  serveResource</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112454772" />
    <author>
      <name>Daniel G</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112454772</id>
    <updated>2019-02-25T10:39:22Z</updated>
    <published>2019-02-25T10:39:22Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Dear all,&lt;br&gt;&lt;br&gt;I am facing an issue when calling ServeResource method.&lt;br&gt;&lt;br&gt;I want to make a portlet which returns an excel file when a button is pressed. The excel has to be generated each time that the button is pressed.&lt;br&gt;&lt;br&gt;My problem is that the excel which is returned is always the same, the first one which is generated. Only if I remove the portlet and put it again, it generates a new excel.&amp;nbsp; &lt;br&gt;&lt;br&gt;Anyone has any idea of why is this happening?&lt;br&gt;&lt;br&gt;I use this in serve resource method:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
res.setContentType("application/vnd.ms-excel");
res.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
ResourceBundle resourceBundle = ResourceBundle.getBundle("content.Language",res.getLocale());
res.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename="+LanguageUtil.get(resourceBundle, "excel.title")+"_"+ System.currentTimeMillis() + ".xls");
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Any help would be very appreciated.&lt;br&gt;&lt;br&gt;&lt;br&gt;Thanks in advance.&lt;br&gt;&lt;br&gt;Kind regards.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Daniel G</dc:creator>
    <dc:date>2019-02-25T10:39:22Z</dc:date>
  </entry>
</feed>
