From 4890e9cdc9b48150e3d97921a0ba8b68f25a60fb Mon Sep 17 00:00:00 2001 From: briancaruso Date: Tue, 12 Jul 2011 20:14:15 +0000 Subject: [PATCH] Adding UTF-8 character encoding to SolrJsonServlet. --- .../webapp/controller/SolrJsonServlet.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SolrJsonServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SolrJsonServlet.java index 78e85e122..eaa7c4844 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SolrJsonServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SolrJsonServlet.java @@ -336,9 +336,11 @@ public class SolrJsonServlet extends VitroHttpServlet { } Map options = SelectListGenerator.getOptions(editConfig, field, (new VitroRequest(req)).getFullWebappDaoFactory()); - resp.setContentType("application/json"); - ServletOutputStream out = resp.getOutputStream(); + + resp.setCharacterEncoding("UTF-8"); + resp.setContentType("application/json;charset=UTF-8"); + ServletOutputStream out = resp.getOutputStream(); out.println("["); for(String key : options.keySet()){ JSONArray jsonObj = new JSONArray(); @@ -405,8 +407,9 @@ public class SolrJsonServlet extends VitroHttpServlet { }catch(JSONException je ){ throw new ServletException(je.getMessage()); } - } - resp.setContentType("application/json"); + } + resp.setCharacterEncoding("UTF-8"); + resp.setContentType("application/json;charset=UTF-8"); ServletOutputStream out = resp.getOutputStream(); out.print( ja.toString() ); log.debug("done with getEntitiesByVClassContinuation()"); @@ -439,9 +442,8 @@ public class SolrJsonServlet extends VitroHttpServlet { VitroRequest vreq = new VitroRequest(req); String vclassURI = vreq.getParameter("vclassURI"); WebappDaoFactory daos = (new VitroRequest(req)).getFullWebappDaoFactory(); - resp.setCharacterEncoding("UTF-8"); - - // ServletOutputStream doesn't support UTF-8 + resp.setCharacterEncoding("UTF-8"); + PrintWriter out = resp.getWriter(); resp.getWriter(); @@ -511,7 +513,7 @@ public class SolrJsonServlet extends VitroHttpServlet { } } - resp.setContentType("application/json"); + resp.setContentType("application/json;charset=UTF-8"); out.print( ja.toString() ); log.debug("done with getEntitiesByVClass()");