List of usage examples for javax.servlet.http HttpServletResponse setStatus
public void setStatus(int sc);
From source file:com.lily.dap.web.util.WebUtils.java
/** * If-None-Match Header,Etag./* www . j a va2 s . c om*/ * * Etag,checkIfNoneMatchfalse, 304 not modify status. */ public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) { String headerValue = request.getHeader("If-None-Match"); if (headerValue != null) { boolean conditionSatisfied = false; if (!headerValue.equals("*")) { StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ","); while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { String currentToken = commaTokenizer.nextToken(); if (currentToken.trim().equals(etag)) { conditionSatisfied = true; } } } else { conditionSatisfied = true; } if (conditionSatisfied) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader("ETag", etag); return false; } } return true; }
From source file:com.dosport.system.utils.ServletUtils.java
/** * ?? If-None-Match Header, Etag?.// ww w .j a v a 2s . co m * * Etag, checkIfNoneMatchfalse, 304 not modify status. * * @param etag * ETag. */ public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) { String headerValue = request.getHeader("If-None-Match"); if (headerValue != null) { boolean conditionSatisfied = false; if (!"*".equals(headerValue)) { StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ","); while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { String currentToken = commaTokenizer.nextToken(); if (currentToken.trim().equals(etag)) { conditionSatisfied = true; } } } else { conditionSatisfied = true; } if (conditionSatisfied) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader("ETag", etag); return false; } } return true; }
From source file:com.handpay.ibenefit.framework.util.WebUtils.java
public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) {//from w w w . jav a 2 s .co m String headerValue = request.getHeader("If-None-Match"); if (headerValue != null) { boolean conditionSatisfied = false; if (!"*".equals(headerValue)) { StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ","); while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { String currentToken = commaTokenizer.nextToken(); if (currentToken.trim().equals(etag)) { conditionSatisfied = true; } } } else { conditionSatisfied = true; } if (conditionSatisfied) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader("ETag", etag); return false; } } return true; }
From source file:cn.com.qiqi.order.utils.Servlets.java
/** * ?? If-None-Match Header, Etag?./*from www. j a va2 s . c om*/ * * Etag, checkIfNoneMatchfalse, 304 not modify status. * * @param etag ETag. */ public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) { String headerValue = request.getHeader(HttpHeaders.IF_NONE_MATCH); if (headerValue != null) { boolean conditionSatisfied = false; if (!"*".equals(headerValue)) { StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ","); while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { String currentToken = commaTokenizer.nextToken(); if (currentToken.trim().equals(etag)) { conditionSatisfied = true; } } } else { conditionSatisfied = true; } if (conditionSatisfied) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader(HttpHeaders.ETAG, etag); return false; } } return true; }
From source file:com.cnksi.core.web.utils.Servlets.java
/** * ?? If-None-Match Header, Etag?./*w w w. j a v a 2 s.c o m*/ * * Etag, checkIfNoneMatchfalse, 304 not modify status. * * @param etag ETag. */ public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) { String headerValue = request.getHeader(HttpHeaders.IF_NONE_MATCH); if (headerValue != null) { boolean conditionSatisfied = false; if (!"*".equals(headerValue)) { StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ","); while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { String currentToken = commaTokenizer.nextToken(); if (currentToken.trim().equals(etag)) { conditionSatisfied = true; } } } else { conditionSatisfied = true; } if (conditionSatisfied) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader(HttpHeaders.ETAG, etag); return false; } } return true; }
From source file:com.netflix.zuul.scriptManager.FilterScriptManagerServlet.java
/** * Set an error code and print out the usage docs to the response with a preceding error message * * @param statusCode// w w w . j a v a 2 s. com * @param response */ private static void setUsageError(int statusCode, String message, HttpServletResponse response) { response.setStatus(statusCode); try { Writer w = response.getWriter(); if (message != null) { w.write(message + "\n\n"); } w.write(getUsageDoc()); } catch (Exception e) { logger.error("Failed to output usage error.", e); // won't throw exception because this is not critical, logging the error is enough } }
From source file:de.escidoc.core.aa.servlet.Login.java
/** * Writes the provided page content to the writer of the {@link HttpServletResponse}. The http status code is set to * the provided value./*from w w w.j ava 2s .c o m*/ * * @param response The {@link HttpServletResponse}. * @param page The page to write. * @param statusCode The http status code to set. * @throws IOException Thrown in case of a failed i/o operation. */ private static void sendResponse(final HttpServletResponse response, final String page, final int statusCode) throws IOException { final PrintWriter writer = response.getWriter(); writer.print(page); response.setStatus(statusCode); }
From source file:com.emaxcore.emaxdata.common.web.Servlets.java
/** * ?? If-None-Match Header, Etag?.//from w ww .j a v a 2 s. c om * * Etag, checkIfNoneMatchfalse, 304 not modify status. * * @param etag ETag. */ public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) { String headerValue = request.getHeader(HttpHeaders.IF_NONE_MATCH); if (headerValue != null) { boolean conditionSatisfied = false; if (!"*".equals(headerValue)) { StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ","); while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { String currentToken = commaTokenizer.nextToken(); if (currentToken.trim().equals(etag)) { conditionSatisfied = true; } } } else { conditionSatisfied = true; } if (conditionSatisfied) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader(HttpHeaders.ETAG, etag); return false; } } return true; }
From source file:com.cultureofcode.diceware.NumberController.java
@ExceptionHandler(IllegalArgumentException.class) public ClientError handleIllegalArgs(IllegalArgumentException iae, HttpServletResponse resp) { resp.setStatus(HttpStatus.BAD_REQUEST.value()); return new ClientError(iae.getMessage()); }
From source file:com.alehuo.wepas2016projekti.controller.RestController.java
/** * Palauttaa kyttjtunnuksia hakusanan perusteella * * @param searchTerm Hakusana//from w w w . ja va2 s .c o m * @param res HTTP Response * @return */ @RequestMapping(value = "/users/{searchTerm}", method = RequestMethod.GET) public List<UserAccount> getUsersMatching(@PathVariable String searchTerm, HttpServletResponse res) { res.setStatus(200); return usrService.getUsersByUsernameLike(searchTerm); }