Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IllegalStateException  RSS feed

 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String filePath="";
String fileNameNew="test.csv";
filePath="C:/testing/"+fileNameNew;
response.setContentType("application/unknown");
response.addHeader("Content-Disposition", "attachment; filename="+fileNameNew);

try{
File uFile= new File(filePath);
int fSize=(int)uFile.length();

PrintWriter pw = response.getWriter();
int c=-1;
System.out.println("1: "+strCSV);
pw.print(strCSV);
System.out.println(strCSV);
// Close output and input resources.
pw.close();
}catch(Exception e){
e.printStackTrace();
}


error:

06/02/28 15:54:01 java.lang.IllegalStateException: OutputStream already retrieved

06/02/28 15:54:01 at com.evermind.server.http.EvermindHttpServletResponse.getWriter(EvermindHttpServletResponse.java:998)

06/02/28 15:54:01 at _mybus_2d_trx._hr._mileagereimbursement._writer._jspService(writer.jsp:149)


PrintWriter pw = response.getWriter(); <--this is line 149 what is this error suppose to mean?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you doing this in a JSP file ?

( I'm tempted to say that you should not do this at all )
[ February 28, 2006: Message edited by: Satou kurinosuke ]
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes im doing this in jsp.. im just copying the codes from the existing codes in our application but when i try to run my own it get the error
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should be ok, but it depends on the way you are calling the JSP file.
How do you redirect to it ?
[ February 28, 2006: Message edited by: Satou kurinosuke ]
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i mean

String filePath="";
String fileNameNew="LMS_HistoryReport.csv";
filePath="/testing/"+fileNameNew;
response.setContentType("application/unknown");
response.addHeader("Content-Disposition", "attachment; filename="+fileNameNew);
try{
File uFile= new File(filePath);
int fSize=(int)uFile.length();
PrintWriter pw = response.getWriter();
int c=-1;
pw.print(strCSV);
// Close output and input resources.
pw.close();
}catch(Exception e){
}



this part is from an existing jsp and is working fine..
when i copied that jsp and modify i get the exception.. so it is possible
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is strCSV ?
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
strCSV is just a string like

strCSV += "Lobby Management System - Expected Guest Report\n";
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so it is possible

Yes it is possible,
but it seems that the response's output stream is already open.
What are you doing before this code ?
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nothing i have some codes but i have put comment on to them because that part is giving me error.. the only java code that is being parsed is that part
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you access the JSP file ? Directly from the address bar of the browser ?
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yup
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yup
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
com.evermind.server.http.EvermindHttpServletResponse

What is this wrapper ? It might be its fault.
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe this is the whole stack trace:

06/02/28 16:25:29 java.lang.IllegalStateException: OutputStream already retrieved

06/02/28 16:25:29 at com.evermind.server.http.EvermindHttpServletResponse.getWriter(EvermindHttpServletResponse.java:998)

06/02/28 16:25:29 at _mybus_2d_trx._hr._mileagereimbursement._writer._jspService(writer.jsp:137)

06/02/28 16:25:29 at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:57)

06/02/28 16:25:29 at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:567)

06/02/28 16:25:29 at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:302)

06/02/28 16:25:29 at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)

06/02/28 16:25:29 at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)

06/02/28 16:25:29 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

06/02/28 16:25:29 at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)

06/02/28 16:25:29 at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)

06/02/28 16:25:29 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:649)

06/02/28 16:25:29 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)

06/02/28 16:25:29 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)

06/02/28 16:25:29 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)

06/02/28 16:25:29 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)

06/02/28 16:25:29 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)

06/02/28 16:25:29 at java.lang.Thread.run(Thread.java:534)

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, there's a lot going on here
I'm wondering if a Servlet of Filter called in this trace is already opening the output stream. That would explain why you can't use getWriter in the JSP file.
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what will i do now?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at the error message again, it seems that the output stream is already opened by EvermindHttpServletResponse, that is why you cannot opened it again in your JSP file
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i write the file?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I can't help more. This seems to be some oc4j related stuff, which I'm not familiar with. I hope some other ranchers will help.

But I would strongly recommend you do this kind of processing into a servlet, instead of a JSP file.
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for you help
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for you help
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!