Add a new option for returning HTML
Currently just renders the JSON into HTML. Should probably look for a "body" attribute and use that as a string... but it doesn't right now.
Showing
1 changed file
with
12 additions
and
0 deletions
... | @@ -492,6 +492,18 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -492,6 +492,18 @@ public class DirectControlServlet extends HttpServlet { |
492 | 492 | ||
493 | setResponseNoCache(); | 493 | setResponseNoCache(); |
494 | 494 | ||
495 | if ("HTML".equals(outputHandler)) { | ||
496 | response.setContentType("text/html; charset=utf-8"); | ||
497 | |||
498 | PrintWriter writer = response.getWriter(); | ||
499 | |||
500 | String jsonStr = JSON.from(result).toString(); | ||
501 | response.setContentLength(jsonStr.getBytes("UTF-8").length); | ||
502 | writer.write(jsonStr); | ||
503 | writer.flush(); | ||
504 | writer.close(); | ||
505 | } | ||
506 | |||
495 | if ("JSON".equals(outputHandler)) { | 507 | if ("JSON".equals(outputHandler)) { |
496 | response.setContentType("application/x-json;charset=UTF-8"); | 508 | response.setContentType("application/x-json;charset=UTF-8"); |
497 | 509 | ... | ... |
-
Please register or sign in to post a comment