WebSphere Application Server - IllegalStateException OutputStream using struts with websphere

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Application Server > March 2004 > IllegalStateException OutputStream using struts with websphere





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author IllegalStateException OutputStream using struts with websphere
d0minat0r

2004-03-05, 8:34 am

Hi,

I'm having problems with downloading files from my application (in
Websphere 5). I have written an action in struts that does the
following thing:

{ String filename =
request.getParameter(VisualConstants.RKEY_SELECTED_DOCUMENT_NAME);
String path =
request.getParameter(VisualConstants.RKEY_SELECTED_DOCUMENT_PATH); File
file = new File(DocumentUtil.getAbsoluteDocumentPath(path));
response.setContentType("application/unknown");
response.setHeader("Content-Disposition", "attachment; filename=\"" +
filename + "\""); long fileLength = file.length();
response.setHeader("Content-Length", new Long(fileLength).toString());
BufferedInputStream bis = new BufferedInputStream(new
FileInputStream(file)); ServletOutputStream stream =
response.getOutputStream(); int data; while ((data = bis.read()) != -1)
{ stream.write(data); } bis.close(); stream.flush(); stream.close();
return mapping.findForward("success"); }

The download works, but I get the download window two times. In my
logging I can see the following thing:

E SRVE0026E: [Servlet Error]-[JSP 1.2 Processor]:
java.lang.IllegalStateException: OutputStream already obtained at com.i-
bm.ws.webcontainer.srt.SRTServletResponse.getWriter(SRTServletResponse.-
java:450) at com.ibm.ws.webcontainer.servlet.HttpServletResponseProxy.g-
etWriter(HttpServletResponseProxy.java:123) at com.ibm.ws.webcontainer.-
servlet.HttpServletResponseProxy.getWriter(HttpServletResponseProxy.jav-
a:123) at com.ibm.ws.webcontainer.servlet.HttpServletResponseProxy.getW-
riter(HttpServletResponseProxy.java:123) ...



--
posted via MFF : http://www.MainFrameForum.com - USENET Gateway
sunnylearns

2004-03-25, 6:34 am

try returning null instead of mapping.findForward("success");

this works.



--
posted via MFF : http://www.MainFrameForum.com - USENET Gateway
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com