Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Response.already.committed  RSS feed

 
Ulas Ergin
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a simple application that sends http request to a servlet via URLConnection.It prints Cannot set header. Response already committed. warning message to the stdout of servlet.

What is wrong with the below code segment?


while (result.next()) {
java.net.URL dataURL = new java.net.URL("http://localhost/MyServlet");
java.net.URLConnection connection1 = dataURL.openConnection();
connection1.setUseCaches(false);
connection1.setDoOutput(true);
connection1.setDoInput(true);
String data = result.getString(5)
String postData = new String("user=X&type=WEB&id=");
postData = postData + data;
java.io.DataOutputStream printout = new java.io.DataOutputStream (connection1.getOutputStream());
printout.writeBytes(postData);
printout.flush();
printout.close();
java.io.BufferedReader input = new java.io.BufferedReader(new java.io.InputStreamReader(connection1.getInputStream()));
String line = null;
StringBuffer returnedFBML = new StringBuffer();
while ((line = input.readLine()) != null) {
returnedFBML.append(line + "\n");
}
input.close();
}




and the log is

[22.11.2004 11:00:27:339 MSK] 2b8d8aac SRTServletRes W WARNING: Cannot set header. Response already committed.
[22.11.2004 11:00:27:382 MSK] 31140aac TraceNLS u No message text associated with key WARNING:.Cannot.set.header..Response.already.committed. in bundle com.ibm.ejs.resources.seriousMessages

any help is appreciated
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if this is your problem, but this statement:



may be closing the whole connection. I don't see where your code catches and reports any IOException if that happens.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!