This content has been marked as final.
Show 5 replies
-
1. Re: Access to response.getOutputStream() via SEAM
gavin.king Jan 31, 2006 12:34 PM (in response to truto)This is a JSF question, but yes, it is possible, by accessing the JSF ExternalContext.
-
2. Re: Access to response.getOutputStream() via SEAM
truto Jan 31, 2006 12:36 PM (in response to truto)I have found a way that seems to work. Not SEAM related I guess, but JSF dependent.
On a bean's method:FacesContext context = FacesContext.getCurrentInstance(); HttpServletResponse res = (HttpServletResponse)context.getExternalContext().getResponse(); ServletOutputStream os = res.getOutputStream(); os.println("Content-type: application/vnd.ms-excel"); os.println(); // write content context.responseComplete();
-
3. Re: Access to response.getOutputStream() via SEAM
truto Jan 31, 2006 12:52 PM (in response to truto)Correction:
HttpServletResponse res = (HttpServletResponse)context.getExternalContext().getResponse(); res.setHeader("Content-type", "application/..."); ServletOutputStream os = res.getOutputStream(); // write content on os context.responseComplete();
-
4. Re: Access to response.getOutputStream() via SEAM
truto Jan 31, 2006 1:06 PM (in response to truto)Gavin, thanks for you answer, I've only seen it now :-(
-
5. Re: Access to response.getOutputStream() via SEAM
amarinis May 22, 2006 10:07 PM (in response to truto)If you do want this to work of osx and probably some other platforms, then you will also need the following line in the code
res.setHeader("Content-disposition", "attachment; filename=aFile.xls");
You may want to store the file name and return that in the above or try to map extensions to mime types. This would depend on its usage.