List of usage examples for java.io PrintWriter print
public void print(Object obj)
From source file:ai.susi.server.api.cms.Sitemap.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Query post = RemoteAccess.evaluate(request); // String siteurl = request.getRequestURL().toString(); // String baseurl = siteurl.substring(0, siteurl.length() - // request.getRequestURI().length()) + request.getContextPath() + "/"; String baseurl = "http://loklak.org/"; JSONObject TopMenuJsonObject = new TopMenuService().serviceImpl(post, null, null, null); JSONArray sitesarr = TopMenuJsonObject.getJSONArray("items"); response.setCharacterEncoding("UTF-8"); PrintWriter sos = response.getWriter(); sos.print(sitemaphead + "\n"); for (int i = 0; i < sitesarr.length(); i++) { JSONObject sitesobj = sitesarr.getJSONObject(i); Iterator<String> sites = sitesobj.keys(); sos.print("<url>\n<loc>" + baseurl + sitesobj.getString(sites.next().toString()) + "/</loc>\n" + "<changefreq>weekly</changefreq>\n</url>\n"); }/*from w w w . j av a 2 s. c om*/ sos.print("</urlset>"); sos.println(); post.finalize(); }
From source file:com.alibaba.dubbo.governance.web.home.module.screen.Shell.java
public void execute(Map<String, Object> context) throws Exception { if (context.get(WebConstants.CURRENT_USER_KEY) != null) { User user = (User) context.get(WebConstants.CURRENT_USER_KEY); currentUser = user;/*www .j a va 2 s .co m*/ operator = user.getUsername(); role = user.getRole(); context.put(WebConstants.CURRENT_USER_KEY, user); } operatorAddress = (String) context.get("request.remoteHost"); context.put("operator", operator); context.put("operatorAddress", operatorAddress); try { String message = doExecute(context); context.put("message", "OK: " + filterERROR(message)); } catch (Throwable t) { context.put("message", "ERROR: " + filterOK(t.getMessage())); } PrintWriter writer = response.getWriter(); writer.print(context.get("message")); writer.flush(); }
From source file:com.googlecode.commonspringaspects.servlets.PerformanceHttpRequestHandler.java
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (!enabled) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return;/*from ww w. ja v a 2 s. c om*/ } if (request.getMethod().equals("POST")) { MonitorFactory.reset(); response.sendRedirect(request.getRequestURI()); } else { response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.print("<html>"); writer.print("<body><form action='' method='post'> <input type='submit' value='Reset JAMon'> </form>"); writer.print(MonitorFactory.getRootMonitor().getReport(3, "desc")); writer.print("</body></html>"); } }
From source file:com.att.api.immn.controller.DeleteSubscriptionController.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final HttpSession session = request.getSession(); JSONObject jresponse = new JSONObject(); try {/*from w w w.ja v a 2 s .c o m*/ if (session.getAttribute("subscriptionId") == null) { throw new RESTException("You must first create a subscription."); } final OAuthToken token = this.getFileToken("notificationScope"); final String channelId = appConfig.getProperty("channelId"); final String subscriptionId = (String) session.getAttribute("subscriptionId"); final String fqdn = appConfig.getApiFQDN(); final WebhooksService srvc = new WebhooksService(fqdn, token); srvc.deleteNotificationSubscription(channelId, subscriptionId); session.removeAttribute("subscriptionId"); jresponse.put("success", true).put("text", "Subscription deleted."); } 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.alibaba.dubbo.governance.web.home.module.screen.Servicestatus.java
public void execute(Map<String, Object> context) throws Exception { String uri = request.getRequestURI(); String contextPath = request.getContextPath(); if (contextPath != null && !"/".equals(contextPath)) { uri = uri.substring(contextPath.length()); }// w w w.j a v a2 s.c o m if (uri.startsWith("/status/")) { uri = uri.substring("/status/".length()); } // Map<String, String> providers = registryCache.getServices().get(uri); // if (providers == null || providers.size() == 0) { // providers = providerDAO.lookup(uri); // } // if (providers == null || providers.size() == 0) { // context.put("message", "ERROR" // + new SimpleDateFormat(" [yyyy-MM-dd HH:mm:ss] ").format(new Date()) // + Status.filterOK("No such any provider for service " + uri)); // } else { // context.put("message", "OK"); // } PrintWriter writer = response.getWriter(); writer.print(context.get("message").toString()); writer.flush(); }
From source file:com.att.api.immn.controller.DelMsgController.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); final String msgIdStr = request.getParameter("deleteMsgId"); final String[] msgIds = msgIdStr.split(","); JSONObject jresponse = new JSONObject(); try {/*from w ww. java2s .c om*/ if (msgIds.length > 1) { srvc.deleteMessages(msgIds); } else { final String msgId = msgIds[0]; srvc.deleteMessage(msgId); } jresponse.put("success", true).put("text", "Message(s) deleted."); } 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.immn.controller.GetMsgIndexInfoController.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 v a 2s . c om final MessageIndexInfo info = srvc.getMessageIndexInfo(); final JSONArray tables = new JSONArray(); final JSONArray values = new JSONArray().put(info.getStatus()).put(info.getState()) .put(info.getMessageCount()); tables.put(new JSONObject().put("caption", "Message Index Info:") .put("headers", new JSONArray().put("Status").put("State").put("Message Count")) .put("values", new JSONArray().put(values))); jresponse.put("success", true).put("tables", tables); } 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:org.codehaus.cargo.sample.testdata.jdbc.TestServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("cargotest"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); TransactionStatus status = txManager.getTransaction(def); try {/* w w w .j a v a 2s .co m*/ dao.create("Adrian", "Cole"); } catch (RuntimeException ex) { txManager.rollback(status); throw ex; } txManager.commit(status); if (dao.selectAll().size() != 1) throw new RuntimeException("Commit didn't work"); PrintWriter out = response.getWriter(); out.print("all good!"); out.close(); }
From source file:be.fedict.eid.dss.sp.servlet.PkiServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("doGet"); String pemCertificate;//from w ww .j a v a2 s .c o m try { pemCertificate = toPem(getPrivateKeyEntry().getCertificate()); } catch (Exception e) { LOG.error(e); return; } response.setContentType("text/plain"); PrintWriter out = response.getWriter(); out.print(pemCertificate); out.close(); }
From source file:com.autobizlogic.abl.mgmt.ConsoleServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { Map<String, String> args = new HashMap<String, String>(); Enumeration<String> paramNames = req.getParameterNames(); while (paramNames.hasMoreElements()) { String paramName = paramNames.nextElement(); String paramValue = req.getParameter(paramName); if (paramValue == null || paramValue.length() == 0) paramValue = null;//w ww . j a v a2 s.com args.put(paramName, paramValue); } Map<String, Object> result = null; String areaName = args.get("area"); if (areaName.equals("SessionFactory")) result = SessionFactoryService.service(args); else if (areaName.equals("ClassMetadata")) result = ClassMetadataService.service(args); else if (areaName.equals("Transactions")) result = TransactionService.service(args); else if (areaName.equals("Performance")) result = PerformanceService.service(args); else if (areaName.equals("Dependency")) result = DependencyService.service(args); if (result == null) return; resp.setContentType("application/json"); String resStr = JSONValue.toJSONString(result); PrintWriter out = resp.getWriter(); out.print(resStr); }