?
Solved

IlligalstateException-output stream already in use

Posted on 2003-10-28
10
Medium Priority
?
824 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 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