Foren

Not able to download file by using JSF portlet

madhav pati, geändert vor 13 Jahren.

Not able to download file by using JSF portlet

New Member Beiträge: 17 Beitrittsdatum: 21.02.11 Neueste Beiträge
Hi all!!

I need to download file by using JSF(richfaces)command button action

In my action method the code is like

FacesContext context = FacesContext.getCurrentInstance();
PortletResponse response = (PortletResponse)context.getExternalContext().getResponse();

//Reading files
String Files = "D:\\test\\err.txt";
File f = new File(Files);
FileInputStream istr = new FileInputStream(Files);
BufferedInputStream bstr = new BufferedInputStream(istr); // promote
int size = (int) f.length(); // get the file size (in bytes)
byte[] data = new byte; // allocate byte array of right size
bstr.read(data, 0, size); // read into byte array
bstr.close();

HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(response);
ServletOutputStream out = httpServletResponse.getOutputStream();

But when i try to access ServletOutputStream object it throw error like

java.lang.IllegalStateException: Cannot obtain OutputStream because Writer is already in use

Please help
madhav pati, geändert vor 13 Jahren.

RE: Not able to download file by using JSF portlet

New Member Beiträge: 17 Beitrittsdatum: 21.02.11 Neueste Beiträge
Is anybody face this issue before? please help!! its urgent emoticon
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: Not able to download file by using JSF portlet

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Please specify your environment when posting a question.

I'm not sure if the following will help you or not:

http://issues.liferay.com/browse/LPS-12063?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel