[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

IlligalstateException-output stream already in use

Posted on 2003-10-28
10
Medium Priority
?
826 Views
Last Modified: 2010-05-18
I am calling response.getOutputStream() and initialing it as below in a jsp file.
  ServeletOutputStream sos=response.getOutputStream() ;
   ....
   ...
   sos.write();
   sos.flush();
   sos.close();
I commented out sos.flush() and sos.close() , but always it give that exception
at the end of the jsp page.

one more thing I am not calling response.getWriter().
and there is no out.write("\r\n"); in my jsp converted java file,sombody told like if out.write("\r\n"); will call the response.getwriter();
0
Comment
Question by:Subramanya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 9639417
why you will need to get the outputstream by your own??
in your jsp if there is even a single space somewhere in the  code you will get this exception...
the reason is that system uses the writer to write the output of jsp ( which is eventually total page - java sniplets)..
post your code here and I should be able to help you out with this.
0
 

Author Comment

by:Subramanya
ID: 9647559
The problem is solved after converting the Jsp into actual java servlet.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10747869
why I shd not be getting the points????
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 35

Expert Comment

by:girionis
ID: 10748262
Hello Kuldeepchaturvedi, I don't see you suggested the Servlet solution so I considered it better to PQ the question and refund the points. I can infer from your comment that your suggestion actually helped the asker.
0
 
LVL 35

Expert Comment

by:girionis
ID: 10748265
sorry this

> I can infer from your comment

should be

I *cannot* infer from your comment
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10748277
>>>in your jsp if there is even a single space somewhere in the  code you will get this exception...
the reason is that system uses the writer to write the output of jsp ( which is eventually total page - java sniplets)..

is equivelent of either don't uses spaces in the jsp or don'y try to get outputstream because jsp will already have it in writer..
a way around this wd have been converting it to servlet....

which I agree that I didn't say explictly but in my opinion my comments was on the right direction..
but I honor your decision.
Thanks
0
 
LVL 35

Expert Comment

by:girionis
ID: 10748395
> s equivelent of either don't uses spaces in the jsp or don'y try to get outputstream because jsp will already have it in writer..

AFAIK spaces do not have anything to do with the problem but you are right on the second part of your latest comment, the implicit output stream is already obtained in the JSP. I would also have expected to indicate that the user could use the ServletOutputStream from the ServletResponse (response object) instead of the implicit JSP "out" variable.

Bare in mind that loads of people are not very experienced with Java (if they were they would ask a question that looks simple to most of us) and in order to have a better understanding of the mechanics you have to be explicit and sedulous.

Anyway, I do not want to be unfair here. My suggestion is just that, a suggestion, a moderator will decide on its final disposition. Therefore I will let a moderator decide and I am sure if (s)he finds your comment was helpful points will be awarded to you :)
0
 
LVL 35

Expert Comment

by:girionis
ID: 10748415
Soryr ignore that again:

>  I would also have expected to indicate that the user could use the ServletOutputStream from the ServletResponse (response object) instead of the implicit JSP "out" variable.

the user already obtains this stream (I think it's time for me to go to bed after so many hours in front of the computer)
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 10784969
PAQed, with points refunded (100)

CetusMOD
Community Support Moderator
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question