{
// This is a complex area as we are trying to keep public and private services properly
// seperated, and trying to keep stateless and stateful (i.e., perthread scope) services
// seperated. So we inform the stateful queue service what it needs to do here ...
ContentType pageContentType = (ContentType) request.getAttribute(
InternalConstants.CONTENT_TYPE_ATTRIBUTE_NAME);
String charset = pageContentType.getParameter(InternalConstants.CHARSET_CONTENT_TYPE_PARAMETER);
ContentType contentType = new ContentType(InternalConstants.JSON_MIME_TYPE);
contentType.setParameter(InternalConstants.CHARSET_CONTENT_TYPE_PARAMETER, charset);
MarkupWriter writer = factory.newMarkupWriter(pageContentType);
JSONObject reply = new JSONObject();
// ... and here, the pipeline eventually reaches the PRQ to let it render the root render command.
partialMarkupRenderer.renderMarkup(writer, reply);
PrintWriter pw = response.getPrintWriter(contentType.toString());
pw.print(reply);
pw.flush();
}