Hi All,
I am following the recommendations at http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pageId=3132 while I download a file from a portlet. I include the request from portlet to servlet using a PortletRequestDispatcher. But while rendering, portal prints the binary contents in the portlet page, instead of giving an option for download. I am using Struts 2 in Liferay 4.2.x. Can you please point out what am I missing here? Thanks and regards, Atanu Dasgupta Here are my code snippets. ===== STRUTS ACTION ====== RenderRequest request = PortletActionContext.getRenderRequest(); String uuid = (String) request.getParameter("reportUuid"); RenderResponse res = PortletActionContext.getRenderResponse(); PortletRequestDispatcher rd = PortletActionContext.getPortletConfig() .getPortletContext().getRequestDispatcher("/download?reportUuid=" + uuid); try { rd.include(request, res); } catch (IOException ioe) { ioe.printStackTrace(); } catch (PortletException pe) { pe.printStackTrace(); ===== SERVLET ====== res.setContentType("application/xdownload"); res.setHeader("Content-Disposition", "attachment; filename=x.pdf"); try { res.setContentLength(report.getData().available()); } catch (IOException e) { e.printStackTrace(); } try { OutputStream os = res.getOutputStream(); InputStream is = report.getData(); // get the actual Data int read = 0; byte[] bytes = new byte[1024]; while((read = is.read(bytes)) != -1) { os.write(bytes, 0, read); } os.flush(); os.close(); is.close(); } catch (IOException ioe) { ioe.printStackTrace(); } -- View this message in context: http://www.nabble.com/Portlets-and-Liferay--tf1836171.html#a11828846 Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]