I need to create a link on a jsp page, to download a file from the server.
I am using a commandlink to invoke an action on click of this link. In the action method, I am trying to get the outputStream of response and this always returns null.
Here goes the sample code.
HttpServletResponse response = (HttpServletResponse) getFacesContext().getExternalContext().getResponse();
response.setContentType("application/force-download");
+response.setHeader("Content-Disposition", "attachment;filename=\"" ++
+ fileName + "\"");+
+ServletOutputStream os = response.getOutputStream();
response.getOutputStream() always returns null in the portlet.
Gping thropught begugger I noticed the response is of type ActionResponseWrapper. Not sure how to get the actual resposnefrom this and get the outputStream.
Any help is appreciated.
Thanks