List of usage examples for javax.servlet.http HttpServletResponse SC_OK
int SC_OK
To view the source code for javax.servlet.http HttpServletResponse SC_OK.
Click Source Link
From source file:org.vbossica.springbox.metrics.PingController.java
@RequestMapping(value = "/metrics/ping", method = RequestMethod.GET) public void process(HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); resp.setHeader("Cache-Control", "must-revalidate,no-cache,no-store"); resp.setStatus(HttpServletResponse.SC_OK); if (message != null || message.isEmpty()) { PrintWriter writer = resp.getWriter(); try {/*from ww w .jav a 2s . c o m*/ writer.println(message); } finally { writer.close(); } } }
From source file:org.jboss.as.test.clustering.ClusterHttpClientUtil.java
public static HttpResponse tryGet(final HttpClient client, final HttpUriRequest r) throws IOException { final long startTime; HttpResponse response = client.execute(r); startTime = System.currentTimeMillis(); while (response.getStatusLine().getStatusCode() != HttpServletResponse.SC_OK && startTime + GRACE_TIME_TO_REPLICATE > System.currentTimeMillis()) { response = client.execute(r);// w ww.j av a 2 s .c o m } return response; }
From source file:de.onyxbits.raccoon.net.ResourceHandler.java
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("application/octet-stream"); response.setStatus(HttpServletResponse.SC_OK); if (target.toLowerCase().endsWith("png")) { response.setContentType("image/png"); }//w w w.j av a 2 s. c om if (target.toLowerCase().endsWith("css")) { response.setContentType("text/css"); } // Prevent path traversal -> all resources must be in /web, no sub // directories. String tmp = target.substring(target.lastIndexOf('/'), target.length()); InputStream in = getClass().getResourceAsStream("/web" + tmp); OutputStream out = response.getOutputStream(); IOUtils.copy(in, out); in.close(); out.flush(); out.close(); baseRequest.setHandled(true); }
From source file:gov.nist.appvet.tool.sigverifier.util.ReportUtil.java
/** * This method returns report information to the AppVet ToolAdapter as ASCII * text and cannot attach a file to the response. *///from w w w . ja v a2 s . c o m public static boolean sendInHttpResponse(HttpServletResponse response, String reportText, ToolStatus reportStatus) { try { response.setStatus(HttpServletResponse.SC_OK); // HTTP 200 response.setContentType("text/html"); response.setHeader("toolrisk", reportStatus.name()); PrintWriter out = response.getWriter(); out.println(reportText); out.flush(); out.close(); log.debug("Returned report"); return true; } catch (IOException e) { log.error(e.toString()); return false; } }
From source file:feedme.controller.AddOrDeleteCategoryServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response);/*from w w w . j ava 2 s . c o m*/ request.setCharacterEncoding("UTF-8"); response.setStatus(HttpServletResponse.SC_OK); String CategoryName = request.getParameter("categoryName").trim(); DbRestaurantsManagement ob = new DbRestaurantsManagement(); boolean flag = false; HashMap<String, Integer> cat = new DbHPOnLoad().getCategories(); for (String se : cat.keySet()) { if (se.contains(CategoryName)) flag = true; } int result = 0; if (!flag) result = ob.addNewCategory(CategoryName); PrintWriter out = response.getWriter(); if (result == 1) { if (isAjax(request) == true) { // Stay in the same page, and sand json message try { cat = new DbHPOnLoad().getCategories(); JSONObject catObj = new JSONObject(); JSONArray catArray = new JSONArray(); for (Entry<String, Integer> entry : cat.entrySet()) { catArray.put( new JSONObject().put("cat_id", entry.getValue()).put("cat_name", entry.getKey())); } catObj.put("categories", catArray); catObj.put("status", true); response.setContentType("application/json"); PrintWriter writer = response.getWriter(); writer.print(catObj); response.getWriter().flush(); } catch (JSONException e) { e.printStackTrace(); } } else { // redirect to othe page } } }
From source file:org.broadleafcommerce.admin.util.controllers.RemoveFileController.java
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { DirectoryFileBean bean = (DirectoryFileBean) command; checkDirectory(bean.getAbsolutePath()); response.setStatus(HttpServletResponse.SC_OK); return super.onSubmit(request, response, command, errors); }
From source file:org.broadleafcommerce.admin.util.controllers.MakeDirectoryController.java
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { DirectoryFileBean bean = (DirectoryFileBean) command; checkDirectory(bean.getAbsolutePath() + File.separator + bean.getName()); response.setStatus(HttpServletResponse.SC_OK); return super.onSubmit(request, response, command, errors); }
From source file:fragment.web.ServiceProviderLogoControllerTest.java
@Test public void testGetTenantLogo() { serviceProviderLogoController.getTenantLogo(response); Assert.assertTrue(response.getContentType().contains("image/")); Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatus()); }
From source file:com.sixt.service.framework.json.JsonRpcResponse.java
public static JsonRpcResponse fromString(String rawResponse) { JsonParser parser = new JsonParser(); JsonObject response = parser.parse(rawResponse).getAsJsonObject(); JsonElement id = response.get("id"); JsonElement errorElement = response.get("error"); int responseStatus = HttpServletResponse.SC_OK; String error;// w w w .ja v a 2 s .co m if (!(errorElement instanceof JsonNull)) { if (errorElement instanceof JsonObject) { error = errorElement.toString(); // try parsing it into RpcCallException to get the HttpStatus from there RpcCallException rpcEx = RpcCallException.fromJson(error); if (rpcEx != null) { responseStatus = rpcEx.getCategory().getHttpStatus(); JsonElement resultElement = response.get("result"); return new JsonRpcResponse(id, resultElement == null ? JsonNull.INSTANCE : resultElement, errorElement, responseStatus); } } error = errorElement.getAsString(); if (StringUtils.isNotBlank(error)) { responseStatus = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; } } JsonElement resultElement = response.get("result"); return new JsonRpcResponse(id, resultElement == null ? JsonNull.INSTANCE : resultElement, errorElement, responseStatus); }
From source file:com.threewks.thundr.view.json.JsonView.java
private void applyDefaults() { if (StringUtils.isBlank(getContentType())) { withContentType(MimeTypes.MIME_APPLICATION_JSON); }//from w ww. j a v a 2s .c om if (StringUtils.isBlank(getCharacterEncoding())) { withCharacterEncoding(StringPool.UTF_8); } if (getStatusCode() == null) { withStatusCode(HttpServletResponse.SC_OK); } }