List of usage examples for javax.servlet.http HttpServletResponse getWriter
public PrintWriter getWriter() throws IOException;
PrintWriter
object that can send character text to the client. From source file:org.openmrs.module.hospitalcore.web.controller.patientsearch.PatientSearchController.java
@RequestMapping(value = "/module/hospitalcore/getPatientResultCount.form", method = RequestMethod.POST) public void getPatientResultCount(@RequestParam("query") String query, HttpServletResponse response) throws IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); BigInteger count = Context.getService(HospitalCoreService.class).getPatientSearchResultCount(query); out.print(count);//from www .j av a 2 s. c o m }
From source file:edu.lafayette.metadb.web.attributesman.ShowAdminDescAttributes.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response)/*from ww w. ja v a 2s . c om*/ */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); try { String projname = (String) request.getSession(false).getAttribute(Global.SESSION_PROJECT); String type = request.getParameter("type"); //MetaDbHelper.note("Trying to get "+type+" attributes for "+projname+"..."); ArrayList<AdminDescAttribute> mdList = AdminDescAttributesDAO.getAdminDescAttributes(projname, type); JSONObject output = new JSONObject(); JSONArray attrList = new JSONArray(); output.put("elements", ElementsDAO.getElementList()); output.put("type", type); if (mdList != null) { //if (mdList.isEmpty()) //mdList.add(new AdminDescAttribute(projname, (type.equals("administrative") ? "identifier" : "title"), "", // type, false, false, false, false, false, false, false, 0)); for (int i = 0; i < mdList.size(); i++) { JSONObject attribute = new JSONObject(); AdminDescAttribute t = mdList.get(i); attribute.put("element", t.getElement()); attribute.put("label", t.getLabel()); attribute.put("id", t.getId()); attribute.put("displayDate", t.isReadableDate()); attribute.put("searchDate", t.isSearchableDate()); attribute.put("large", t.isLarge()); attribute.put("controlled", t.isControlled()); attribute.put("multiple", t.isMultiple()); attribute.put("additions", t.isAdditions()); attribute.put("sorted", t.isSorted()); attribute.put("error", t.isError()); attribute.put("vocab", AdminDescAttributesDAO.getControlledVocab(t.getId())); attrList.put(attribute); } output.put("data", attrList); } out.print(output); } catch (Exception e) { MetaDbHelper.logEvent(e); } out.close(); }
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 w w.j av a 2s. c o m*/ resp.getWriter().close(); }
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 w w. j a va 2 s . c om*/ 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:org.dspace.app.webui.cris.controller.RSSStatController.java
public ModelAndView monthly(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception { arg1.setContentType("application/rss+xml"); processRSSStat(arg0, StatSubscription.FREQUENCY_MONTHLY).output(arg1.getWriter()); arg1.getWriter().flush();//from ww w. j a v a2 s . c o m return null; }
From source file:com.android.get.AndroidJSONMethod.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try {/*from w w w. ja va 2 s .c o m*/ String fn = request.getParameter("un"); String pw = request.getParameter("pw"); JSONObject jo = new JSONObject(); if (fn.equals("abc") && pw.equals("123")) { jo.put("fname", "Lakmal"); jo.put("lname", "navarathne"); } out.write(jo.toJSONString()); } finally { out.close(); } }
From source file:com.npower.wurfl.WurflServletInit.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/plain"); PrintWriter out = response.getWriter(); out.println("Init servlet (Loaded on startup for WURFL initialization)"); }
From source file:edu.lafayette.metadb.web.userman.ShowUsers.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) *//*from ww w. jav a 2 s .c om*/ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub PrintWriter out = response.getWriter(); JSONObject output = new JSONObject(); JSONArray admins = new JSONArray(); JSONArray workers = new JSONArray(); JSONObject permissions = new JSONObject(); try { ArrayList<User> userList = UserManDAO.getUserList(); for (User u : userList) { JSONObject user = new JSONObject(); JSONObject info = new JSONObject(); info.put("auth_type", u.getAuthType()); info.put("user_type", u.getType()); user.put("username", u.getUserName()); permissions.put(u.getUserName(), info); if (u.getType().equals("admin")) admins.put(user); else workers.put(user); } output.put("admins", admins); output.put("workers", workers); output.put("permissions", permissions); out.print(output); } catch (Exception e) { MetaDbHelper.logEvent(e); } out.flush(); }
From source file:fr.penet.servlet.ResumeCrawlServlet.java
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); String runIdString = req.getParameter("id"); if (StringUtils.isEmpty(runIdString)) { resp.getWriter().println("Error : empty id parameter"); return;/* www. j a va2 s . co m*/ } if (!StringUtils.isNumeric(runIdString)) { resp.getWriter().println("Error : id parameter is not an integer"); return; } int runId = Integer.parseInt(runIdString); String threads = req.getParameter("threads"); int threadInt = 5; if (StringUtils.isNumeric(threads)) { threadInt = Integer.parseInt(threads); } CustomCrawler crawler = new CustomCrawler(); crawler.resumeCollectUrls(runId, threadInt); resp.getWriter().println("Crawler run with id " + runId + " resumed with " + threadInt + " threads"); }
From source file:UsingContexts.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); HttpSession session = request.getSession(true); Integer counter2 = (Integer) getServletContext().getAttribute("counter2"); if (counter2 == null) { counter2 = new Integer(1); } else {// w ww. j ava 2s .c o m counter2 = new Integer(counter2.intValue() + 1); } getServletContext().setAttribute("counter2", counter2); Integer counter = (Integer) session.getAttribute("counter"); if (counter == null) { counter = new Integer(1); } else { counter = new Integer(counter.intValue() + 1); } session.setAttribute("counter", counter); out.println("<HTML>"); out.println("<HEAD>"); out.println("<TITLE>"); out.println("Using Contexts"); out.println("</TITLE>"); out.println("</HEAD>"); out.println("<BODY>"); out.println("<H1>Using Contexts</H1>"); out.println("Welcome! You have been here " + counter + " times.<BR>"); out.println("Total page accesses: " + counter2 + "<BR>"); if (session.isNew()) { out.println("This is a new session.<BR>"); } else { out.println("This is not a new session.<BR>"); } out.println("The session ID: " + session.getId() + "<BR>"); out.println("Last time accessed: " + new Date(session.getLastAccessedTime()) + "<BR>"); out.println("Creation time: " + new Date(session.getCreationTime()) + "<BR>"); out.println("Timeout length: " + session.getMaxInactiveInterval() + " seconds<BR>"); out.println("</BODY>"); out.println("</HTML>"); }