serializer.reset();
final OutputStream sout = response.getOutputStream();
final PrintWriter output = new PrintWriter(new OutputStreamWriter(sout, encoding));
final SerializerPool serializerPool = SerializerPool.getInstance();
final SAXSerializer sax = (SAXSerializer) serializerPool.borrowObject(SAXSerializer.class);
try {
sax.setOutput(output, serializeOptions);
serializer.setProperties(serializeOptions);
serializer.setSAXHandlers(sax, sax);
serializer.toSAX(inputNode, 1, inputNode.getItemCount(), false, false);
} catch (final SAXException e) {
e.printStackTrace();
throw new IOException(e);
} finally {
serializerPool.returnObject(sax);
}
output.flush();
output.close();
//commit the response