* a FORM_POST method.
*/
public void buildAndWrite() {
try {
RouterController routerController = RequestContextUtils.getWebApplicationContext(request).getBean(
RouterController.class);
if (isMultipart()) {
response.setContentType(RouterController.TEXT_HTML.toString());
response.setCharacterEncoding(RouterController.TEXT_HTML.getCharSet().name());
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
bos.write("<html><body><textarea>".getBytes("UTF-8"));
String responseJson = routerController.getJsonHandler().getMapper()
.writeValueAsString(extDirectResponse);
responseJson = responseJson.replace(""", "\\"");
bos.write(responseJson.getBytes("UTF-8"));
bos.write("</textarea></body></html>".getBytes("UTF-8"));
response.setContentLength(bos.size());
FileCopyUtils.copy(bos.toByteArray(), response.getOutputStream());
} else {
routerController.writeJsonResponse(response, extDirectResponse, routerController.getConfiguration()
.isStreamResponse());
}
} catch (IOException e) {
LogFactory.getLog(getClass()).error("buildAndWrite", e);
throw new RuntimeException(e);