List of usage examples for javax.servlet.http HttpServletResponse setCharacterEncoding
public void setCharacterEncoding(String charset);
From source file:com.fengduo.bee.commons.exception.SystemExceptionResolver.java
/** * Response responseText//w w w . java 2s . co m * * @param response * @param errorMsg */ private void printJSON(HttpServletResponse response, String errorMsg) { response.setCharacterEncoding("UTF-8"); try { PrintWriter out = response.getWriter(); out.println(errorMsg); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:io.dfox.junit.http.example.NoteServlet.java
private void addBasicHeaders(final HttpServletResponse response) { response.setCharacterEncoding(UTF_8); response.addHeader(ACCESS_CONTROL_ALLOW_ORIGIN, EXAMPLE_CLIENT_HOST); }
From source file:de.topicmapslab.majortom.server.http.util.JSONView.java
@Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("UTF-8"); if (callback != null) { response.setContentType("application/javascript"); response.getWriter().write(callback); response.getWriter().write("("); response.getWriter().write(jsonString); response.getWriter().write(");"); } else {//from www . j a v a 2 s . com response.setContentType("application/json"); response.getWriter().write(jsonString); } }
From source file:com.griddynamics.banshun.web.View.java
@Override protected void renderMergedOutputModel(final Map<String, Object> model, final HttpServletRequest request, final HttpServletResponse response) throws Exception { response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.getOutputStream().write(model.toString().getBytes()); response.getOutputStream().close();/*from w ww .j ava 2s .c om*/ }
From source file:com.st.qunar.order.web.order.OrderController.java
@RequestMapping(value = "export") public void mockQnOrderExportServer(HttpServletResponse resp) throws IOException { resp.setCharacterEncoding("UTF-8"); PrintWriter pw = resp.getWriter(); String xml = FileUtils.readFileToString(new File("qn?50?.xml")); System.out.println("getFile:" + xml); pw.write(xml);/*from www . ja va2s . c o m*/ pw.close(); }
From source file:eu.delving.services.controller.SearchApiController.java
@RequestMapping("/api/search") public void searchApiController(HttpServletRequest request, Locale locale, HttpServletResponse response) throws Exception { response.setCharacterEncoding("UTF-8"); response.getWriter()//from w ww. j a v a2 s . c om .write(richApiServiceFactory.getApiResponse(request, locale, ThemeFilter.getLookup(), response)); response.getWriter().close(); }
From source file:com.st.qunar.order.web.order.OrderController.java
@RequestMapping(value = "allExport") public void allExport(@RequestParam String key, HttpServletResponse resp) throws IOException { resp.setCharacterEncoding("UTF-8"); PrintWriter pw = resp.getWriter(); if (key.equalsIgnoreCase("kxhu")) { orderExportService.allExport();/*from www. j ava 2 s . com*/ pw.write("allexport"); } else { pw.write("error key all export"); } pw.close(); }
From source file:com.dm.platform.servlet.IndexServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); try (PrintWriter out = response.getWriter()) { out.println("<!DOCTYPE HTML>"); out.println("<HTML>"); out.println(" <HEAD>"); out.println(" <TITLE>A Servlet</TITLE>"); out.println(" <meta http-equiv=\"content-type\" " + "content=\"text/html; charset=utf-8\">"); out.println(" </HEAD>"); out.println(" <BODY>"); out.println(" Hello AnnotationServlet."); out.println(" </BODY>"); out.println("</HTML>"); out.flush();/*from w w w. j a v a 2 s.c o m*/ } }
From source file:io.hawt.testing.env.builtin.EmptyJolokiaEnvironment.java
@Override public void handle(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("application/json"); resp.setCharacterEncoding("UTF-8"); if (req.getPathInfo().equals("")) { resp.getWriter().print(handle(RequestType.VERSION).toJSONString()); }//from w ww . j ava 2 s . co m resp.getWriter().close(); }
From source file:ru.mystamps.web.controller.RobotsTxtController.java
@GetMapping(Url.ROBOTS_TXT) @SuppressWarnings("PMD.AvoidDuplicateLiterals") public void getRobotsText(HttpServletResponse response) { response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); try {//w w w. j a v a 2s . c o m PrintWriter writer = response.getWriter(); writer.println("# robots.txt for " + Url.PUBLIC_URL); writer.println("User-Agent: *"); writer.println("Disallow: " + Url.REGISTRATION_PAGE); writer.println("Disallow: " + Url.ACTIVATE_ACCOUNT_PAGE); writer.println("Disallow: " + Url.AUTHENTICATION_PAGE); writer.println("Disallow: " + Url.LOGIN_PAGE); writer.println("Disallow: " + Url.ADD_COUNTRY_PAGE); writer.println("Disallow: " + Url.ADD_SERIES_PAGE); writer.println("Disallow: " + Url.ADD_CATEGORY_PAGE); writer.println("Disallow: " + Url.FORBIDDEN_PAGE); writer.println("Disallow: " + Url.NOT_FOUND_PAGE); writer.println("Disallow: " + Url.INTERNAL_ERROR_PAGE); writer.println("Sitemap: " + Url.PUBLIC_URL + Url.SITEMAP_XML); } catch (IOException ex) { LOG.error("Can't return robots.txt: {}", ex.getMessage()); } }