• Register
0 votes
568 views

Problem :

I got following exception from my servlet:
java.lang.illegalstateexception: response has already been committed
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

1. Usually the error comes when you are writing on the output stream from jsp and then again performing some operation on it. 

2. This causes IllegalStateException

3. You should not perform any operation when the response is already committed. 

4. By committed means the response is sent back to the client. 

5. A common scenario is 

OutputStream stream = response.getOutPutStream();

stream.write("something here"); 

stream.flush(); 

RequestDispatcher rd = request.getRequestDispatcher("someFile.jsp");

 rd.forward(request, response);// You must not do this as the stream is already written

9 7 4
38,600 points

Related questions

0 votes
1 answer 2K views
2K views
Problem : I am trying to pass the values from the servlet to jsp page But when I run the page I am facing below error: Error as below : java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed org.apache.catalina.connector. ... getRequestDispatcher("usertaskpage.jsp"); dd.forward(request, response); But still I got a same error. How can I fix above error?
asked Feb 3, 2020 jwilliam 3.9k points
1 vote
1 answer 3 views
3 views
Problem: Any clue to this? Java.lang.illegalstateexception: response has already been committed.
asked May 2 PkGuy 23.5k points
0 votes
1 answer 12 views
12 views
Problem: Is anyone available to assist me and resolve this issue? java.lang.illegalstateexception: cannot call senderror() after the response has been committed
asked Apr 7 Ifra 37.2k points
0 votes
1 answer 71 views
71 views
Problem : I am trying to run Java Applet and getting bellow error. java.lang.illegalstateexception: failed to create a child event loop
asked Oct 31, 2019 peterlaw 6.9k points
0 votes
1 answer 670 views
670 views
Problem : I am just a beginner in java coding. Recently i got this error and was unable to solve it. Please help me with this. exception in thread "main" java.lang.illegalstateexception: scanner closed
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 279 views
279 views
Problem : I am getting bellow error java.sql.sqlexception lock wait timeout exceeded try restarting transaction I am using Java Struts 2.1 Hibernate configuration. DB Used is MYSQL. Anyone know how to solve it..??
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 23 views
23 views
How is this problem caused and how can I solve it? I am using Mojarra 2.1.2.
asked Jan 24 TeamScript 13.5k points
0 votes
1 answer 22 views
22 views
Does anybody know *why* that includes has to be used?
asked Jan 20 TeamScript 13.5k points
0 votes
1 answer 45 views
45 views
I am unable to spot the problem. Any help?
asked Jan 1 TeamScript 13.5k points
0 votes
1 answer 3 views
3 views
Problem: Is there a solution for this? > Java.lang.illegalstateexception: binder has been finalized!
asked 3 days ago Irenka Kiri 17.9k points