Search code examples
jsptomcatjson-simple

Internal error flushing the buffer in release() in jsp when writing custom output


I m writing json data using the json simple library here

Now the code runs fine and im able to get the output. the code being -

<%@page contentType="application/json" pageEncoding="UTF-8" 
import="org.json.simple.JSONObject"%>
<%
JSONObject json = new JSONObject();
newa.NewClass1 newca = new newa.NewClass1();
try {
String s_id = session.getAttribute("id").toString();

json.put("count", newca.get_update_count(s_id)  );
   } catch (Exception e) { json.put("count", "0" ); }    
out.println(json);
json.clear();
out.flush();
out.close();
%>

Now everytime i hit the page i get a warning in the server logs -

WARNING: Internal error flushing the buffer in release()

How do I flush the buffer as I have used the out.flush in the code.

Regards


Solution

  • I believe the "out.close()" might be causing your problem. You should not need to explicitly close() the output stream, so try removing that. I think that there is an implicit flush() and close() going to happen once your JSP has been executed, and by issuing an explicit close() you are causing the downstream flush() to break.