List of usage examples for javax.servlet.http HttpServletResponse setCharacterEncoding
public void setCharacterEncoding(String charset);
From source file:com.asual.summer.xml.XmlView.java
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType(getContentType()); response.setCharacterEncoding(request.getCharacterEncoding()); XmlMapper mapper = new XmlMapper(); mapper.configure(Feature.AUTO_CLOSE_TARGET, false); mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true); mapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true); mapper.writeValue(response.getOutputStream(), filterModel(model)); }
From source file:net.sf.appstatus.web.pages.AbstractPage.java
protected void setup(HttpServletResponse resp, String type) throws IOException { resp.setContentType(type);/*from w w w .j ava 2s . c om*/ resp.setCharacterEncoding(ENCODING); }
From source file:com.thoughtworks.go.spark.SparkPreFilter.java
private void render404(HttpServletResponse response) throws IOException { response.setStatus(404);//from w w w.j a va 2 s . c o m response.setCharacterEncoding("utf-8"); response.setContentType("text/plain"); response.getOutputStream().println("The url you are trying to reach appears to be incorrect."); }
From source file:feedme.controller.AddOrDeleteCategoryServlet.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("UTF-8"); }
From source file:mecha.http.servlets.ProxyServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/* www . j a va2 s . c om*/ response.setCharacterEncoding("UTF-8"); response.setHeader("Access-Control-Allow-Origin", "*"); Map<String, String[]> requestParamMap = request.getParameterMap(); String u = requestParamMap.get("u")[0]; response.getWriter().print(HTTPUtils.fetch(u)); } catch (Exception ex) { Mecha.getMonitoring().error("mecha.http.servlets.macro-servlet", ex); ex.printStackTrace(); } }
From source file:pl.maciejwalkowiak.plist.spring.PlistView.java
@Override protected void prepareResponse(HttpServletRequest request, HttpServletResponse response) { response.setContentType(getContentType()); response.setCharacterEncoding(ENCODING); if (this.disableCaching) { response.addHeader("Pragma", "no-cache"); response.addHeader("Cache-Control", "no-cache, no-store, max-age=0"); response.addDateHeader("Expires", 1L); }//from w w w. j a v a 2 s . com }
From source file:ems.web.controller.other.ResumeController.java
@RequestMapping(value = "/spellCheck", method = RequestMethod.POST) @ResponseBody// w w w .j ava 2 s. c o m public void speelCheck(String data, HttpServletResponse response) { response.setCharacterEncoding("UTF-8"); try { response.getWriter().println(resumeServiceImpl.spellCheck(data)); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.motechproject.server.demo.web.CallMeController.java
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); String phoneNumber = request.getParameter("phone"); int delay = Integer.parseInt(request.getParameter("callDelay")); Calendar now = Calendar.getInstance(); now.add(Calendar.MINUTE, delay); Date callTime = now.getTime(); ModelAndView mav = new ModelAndView(); demoService.schedulePhoneCall(phoneNumber, callTime); mav.setViewName("successView"); return mav;// ww w.j a v a 2 s .c om }
From source file:com.suntek.gztpb.controller.ChangeCarControll.java
@RequestMapping(value = "saveCarInfo.htm", method = RequestMethod.POST) public @ResponseBody String saveTest(CarChangeModel carInfo, HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); PrintWriter out = response.getWriter(); String applyNum = IdGenerator.getInstance().getBizCode("ITMS_SEQ", 5); carInfo.setApplynum(applyNum);/*from w ww . j av a 2s . co m*/ carInfo.setCreatedtime(new Date()); carInfo.setFirstregdate(new Date()); carInfo.setFinish(0); carInfo.setSource(0); carInfo.setSubmittime(new Date()); carInfo.setCreator(request.getParameter("ownername")); try { carChangeService.signUp(carInfo); out.write("<script>parent.saveCallback(1,'" + applyNum + "')</script>"); } catch (Exception e) { e.printStackTrace(); out.write("<script>parent.saveCallback(0)</script>"); } return null; }
From source file:com.gae.UserAdminServlet.java
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); resp.setCharacterEncoding("utf-8"); //PrintWriter out = resp.getWriter(); String userid = req.getParameter("userid"); String passwd = req.getParameter("passwd"); String rv = ""; try {/*ww w . j av a 2 s. c om*/ Entity useradmin = ds.get(KeyFactory.createKey("useradmin", userid)); //1 String passwd2 = useradmin.getProperty("passwd").toString(); //2 String uclass = useradmin.getProperty("uclass").toString(); if (passwd.equals(passwd2)) { Entity userdirec = ds.get(KeyFactory.createKey("userdirec", uclass)); //1 String udirec = userdirec.getProperty("udirec").toString(); rv = "{\"status\": \"" + "OK" + "\", \"udirec\": \"" + udirec + "\"}"; } else { //rv = "????????????"; //rv = "{\"status\": \"" + "NO" + "\", \"reason\": \"" + "????????????" + "\"}"; rv = "{\"status\": \"" + "NO" + "\", \"comment\": \"????????????\"}"; } } catch (EntityNotFoundException e) { //rv = "Error = " + e; rv = "{\"status\": \"" + "NO" + "\", \"comment\": \"" + e + "\"}"; } catch (Exception e) { //rv = "Error = " + e; rv = "{\"status\": \"" + "NO" + "\", \"comment\": \"" + e + "\"}"; } //out.println(rv); resp.getWriter().println(rv); }