List of usage examples for java.io PrintWriter print
public void print(Object obj)
From source file:com.alibaba.dubbo.governance.web.home.module.screen.Status.java
public void execute(Map<String, Object> context) throws Exception { //FIXME cache ? Map<String, com.alibaba.dubbo.common.status.Status> statuses = StatusManager.getInstance() .getStatusList(new String[] { "cache" }); com.alibaba.dubbo.common.status.Status status = StatusManager.getInstance().getStatusSummary(statuses); Level level = status.getLevel(); if (!com.alibaba.dubbo.common.status.Status.Level.OK.equals(level)) { context.put("message", level + new SimpleDateFormat(" [yyyy-MM-dd HH:mm:ss] ").format(new Date()) + filterOK(status.getMessage())); } else {// w w w . j a v a 2 s. co m context.put("message", level.toString()); } PrintWriter writer = response.getWriter(); writer.print(context.get("message").toString()); writer.flush(); }
From source file:org.jamwiki.servlets.StylesheetServlet.java
/** * *//*www . j a v a 2s.c o m*/ public ModelAndView handleJAMWikiRequest(HttpServletRequest request, HttpServletResponse response, ModelAndView next, WikiPageInfo pageInfo) throws Exception { String virtualWiki = pageInfo.getVirtualWikiName(); String stylesheet = ServletUtil.cachedContent(request.getContextPath(), request.getLocale(), virtualWiki, WikiBase.SPECIAL_PAGE_SYSTEM_CSS, false); stylesheet += '\n' + ServletUtil.cachedContent(request.getContextPath(), request.getLocale(), virtualWiki, WikiBase.SPECIAL_PAGE_CUSTOM_CSS, false); response.setContentType("text/css"); response.setCharacterEncoding("UTF-8"); // cache for 30 minutes (60 * 30 = 1800) // FIXME - make configurable response.setHeader("Cache-Control", "max-age=1800"); PrintWriter out = response.getWriter(); out.print(stylesheet); out.close(); // do not load defaults or redirect - return as raw CSS return null; }
From source file:com.adito.util.Utils.java
/** * Given an iterator, prints it as a comma-delimited list * (actually a comma-and-space delimited list). E.g. If the * iterator contains the strings { "my", "dog", "has fleas" } it * will print "my, dog, has fleas"./*from w w w.j a v a 2s.co m*/ * * @param out the stream to write to * @param i an iterator containing printable (toString) objects, e.g. strings **/ public static void printCommaList(PrintWriter out, Iterator i) { boolean first = true; while (i.hasNext()) { if (first) first = false; else out.print(", "); out.print(i.next()); } }
From source file:com.teamexception.reseravationmaven.controller.VehicleTypeController.java
@RequestMapping(value = "allVehicleTypes", method = RequestMethod.GET) public void getAllVehilceTypes(HttpServletResponse resp) throws ClassNotFoundException, SQLException, IOException { ArrayList<VehicleType> types = typeDAO.getAllVehilcesTypes(); String txt = "<select id=\"type\" class=\"form-control\" name=\"vehicleType\">"; for (VehicleType type : types) { txt += "<option>" + type.getVehicleName() + "</option>"; }/*from w w w.j a va2s.co m*/ txt += "</select>"; txt += "<a href=\"addNewVehicleType.jsp\">Add New Vehicle Type</a>"; PrintWriter out = resp.getWriter(); out.print(txt); out.close(); }
From source file:ro.allevo.fintpws.security.CustomAccessDeniedHandler.java
@Produces(MediaType.APPLICATION_JSON) @Override// w w w.j ava2 s.c om public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException exception) throws IOException, ServletException { response.setContentType("application/json"); response.setStatus(403); try { JSONObject obj = JsonResponseWrapper.getEntity(Status.FORBIDDEN.getStatusCode(), ERROR_FORBIDDEN, null, null); PrintWriter out = response.getWriter(); out.print(obj); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.att.api.immn.controller.CreateIndexController.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final HttpSession session = request.getSession(); OAuthToken token = (OAuthToken) session.getAttribute("token"); IMMNService srvc = new IMMNService(appConfig.getApiFQDN(), token); JSONObject jresponse = new JSONObject(); try {/*from w w w.j a va2 s . c o m*/ srvc.createMessageIndex(); jresponse.put("success", true).put("text", "Message index created."); } catch (RESTException re) { jresponse.put("success", false).put("text", re.getMessage()); } response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.print(jresponse); writer.flush(); }
From source file:com.att.api.sms.controller.LoadController.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final HttpSession session = request.getSession(); JSONObject jresponse = new JSONObject().put("authenticated", true).put("server_time", DateUtil.getTime()) .put("download", this.appConfig.getProperty("linkDownload")) .put("github", this.appConfig.getProperty("linkGithub")) .put("short_code_check", this.appConfig.getProperty("getMsgsShortCode")) .put("short_code_received", this.appConfig.getProperty("receiveMsgsShortCode")); final String savedData = (String) session.getAttribute("savedData"); if (savedData != null) { final JSONObject jsavedData = new JSONObject(savedData); jresponse.put("savedData", jsavedData); }/*w w w . ja v a 2s . c o m*/ response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.print(jresponse); writer.flush(); }
From source file:SynchronizedQueue.java
public QueueObjectSerializer<T> getDefaultSerializer() { if (defaultSerializer == null) { defaultSerializer = new QueueObjectSerializer<T>() { public void serialize(PrintWriter writer, T t) { writer.print(t.toString()); }/* w w w .java 2 s . c om*/ }; } return defaultSerializer; }
From source file:be.fedict.eid.idp.sp.PublicKeyServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("doGet"); String pemPrivate;/*w w w . ja v a2s . c o m*/ try { pemPrivate = toPem(PkiServlet.getPrivateKeyEntry().getCertificate().getPublicKey()); } catch (Exception e) { LOG.error(e); return; } response.setContentType("text/plain"); PrintWriter out = response.getWriter(); out.print(pemPrivate); out.close(); }
From source file:com.taobao.ad.easyschedule.servlet.ScheduleJobServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { JobData jobdata = HttpJobUtils.createJobData(request); JobResult result = null;/*from w w w .j a va 2s .co m*/ String beanId = jobdata.getData().get(JobData.JOBDATA_DATA_BEANID); if (StringUtils.isEmpty(beanId)) { result = JobResult.errorResult(JobResult.RESULTCODE_PARAMETER_ILLEGAL, "???"); } else { try { WebApplicationContext context = WebApplicationContextUtils .getWebApplicationContext(this.getServletContext()); JobExecutor executor = (JobExecutor) context.getBean(beanId); result = HttpJobExecutor.getInstance().execute(jobdata, executor); } catch (BeansException e) { result = JobResult.errorResult(JobResult.RESULTCODE_PARAMETER_ILLEGAL, "beanid???" + e.getMessage()); logger.warn("beanid???", e); } } JSONObject json = (JSONObject) JSONObject.toJSON(result); response.setContentType("application/json;charset=utf-8"); PrintWriter out = response.getWriter(); out.print(json.toString()); }