• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes

Problem :

I got following exception from my servlet:
java.lang.illegalstateexception: response has already been committed
by (6.9k points)  

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"); 


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

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

by (36.1k points)