List of usage examples for javax.servlet.http HttpServletResponse getStatus
public int getStatus();
From source file:oobbit.controllers.CustomErrorController.java
/** * Displays the error to the user using ErrorObject. * * @param request HttpServletRequest made by the user * @param response HttpServletResponse made by the server * @param model Model to be included in the page * * @return template as a string/* ww w.jav a2 s. co m*/ */ @RequestMapping(value = PATH) public String errorPage(HttpServletRequest request, HttpServletResponse response, Model model) { RequestAttributes requestAttributes = new ServletRequestAttributes(request); model.addAttribute("error", new ErrorObject(response.getStatus(), errorAttributes.getErrorAttributes(requestAttributes, INCLUDE_STACKTRACE))); return "error"; }
From source file:cn.guoyukun.spring.web.filter.DebugRequestAndResponseFilter.java
private void debugResponse(HttpServletResponse response) { log.debug("=====================response begin=========================="); log.debug("status:{}", response.getStatus(), response.getContentType()); log.debug("contentType:{}, characterEncoding:{}", response.getContentType(), response.getCharacterEncoding()); log.debug("===header begin============================================"); Collection<String> headerNames = response.getHeaderNames(); for (String name : headerNames) { String value = StringUtils.join(response.getHeaders(name), "||"); log.debug("{}={}", name, value); }//from w ww . jav a 2 s .c om log.debug("===header end============================================"); log.debug("=====================response end=========================="); }
From source file:org.bahmni.module.bahmnicore.web.filter.CacheHeadersFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(request, response);//from www . j ava 2 s.co m if (response instanceof HttpServletResponse) { HttpServletResponse httpResponse = (HttpServletResponse) response; HttpServletRequest httpRequest = (HttpServletRequest) request; if ("GET".equals(httpRequest.getMethod()) && httpResponse.getStatus() == 200) { int expiresDuration = NumberUtils.toInt(Context.getAdministrationService() .getGlobalProperty("bahmni.cacheHeadersFilter.expiresDuration"), 0); log.debug(String.format("Setting expires header with duration %s", expiresDuration)); httpResponse.setDateHeader("Expires", DateUtils.addMinutes(new Date(), expiresDuration).getTime()); } } }
From source file:org.dspace.app.rest.BitstreamContentRestController.java
private boolean isNotAnErrorResponse(HttpServletResponse response) { Response.Status.Family responseCode = Response.Status.Family.familyOf(response.getStatus()); return responseCode.equals(Response.Status.Family.SUCCESSFUL) || responseCode.equals(Response.Status.Family.REDIRECTION); }
From source file:org.springframework.boot.actuate.autoconfigure.MetricsFilter.java
private int getStatus(HttpServletResponse response) { try {/*w ww . ja va2 s . c o m*/ return response.getStatus(); } catch (Exception ex) { return UNDEFINED_HTTP_STATUS; } }
From source file:cn.sel.wetty.interceptor.AccessLogger.java
private void o(HttpServletRequest request, HttpServletResponse response) { String msg = String.format("%s\t[%s] -> %s \tStatus:%s\tHeaders:%s", request.getRequestURI(), request.getMethod(), request.getRemoteAddr(), response.getStatus(), getHeaders(response)); LOGGER.info(msg);// www . j av a2s . com }
From source file:nl.ctrlaltdev.harbinger.evidence.Evidence.java
public Evidence(Evidence src, HttpServletResponse resp) { this(src); this.statusCode = resp.getStatus(); }
From source file:org.italiangrid.storm.webdav.server.LogRequestFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(request, response);//from w w w .j a v a 2 s. c o m SecurityContext ctxt = SecurityContextHolder.getContext(); HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; String resMsg = String.format("%s %s %s %d [user:<%s>, authorities:<%s>]", req.getRemoteAddr(), req.getMethod(), req.getRequestURI(), res.getStatus(), ctxt.getAuthentication().getName(), ctxt.getAuthentication().getAuthorities()); log.info(resMsg); }
From source file:com.github.lynxdb.server.api.http.Interceptor.java
@Override public void afterCompletion(HttpServletRequest _request, HttpServletResponse _response, Object _handler, Exception _ex) {// w w w.j a v a 2 s .c o m long time = System.currentTimeMillis() - (long) _request.getAttribute("startTime"); int status = _response.getStatus(); if (status < 400) { if (_request.getRequestURI().startsWith("/api/query")) { monitor.queryOK.incrementAndGet(); monitor.queryLatencies.add((int) time); } else if (_request.getRequestURI().startsWith("/api/put")) { monitor.putOK.incrementAndGet(); monitor.putLatencies.add((int) time); } else { monitor.httpLatencies.add((int) time); } monitor.http2xx.incrementAndGet(); } else { if (_request.getRequestURI().startsWith("/api/query")) { monitor.queryFAIL.incrementAndGet(); } else if (_request.getRequestURI().startsWith("/api/put")) { monitor.putFAIL.incrementAndGet(); } if (status < 500) { monitor.http4xx.incrementAndGet(); } else { monitor.http5xx.incrementAndGet(); } } }
From source file:net.gbmb.collector.FlowFilter.java
@Override public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception { LOGGER.debug("OUT FILTER {} / {} >> {}", httpServletRequest.getMethod(), httpServletRequest.getRequestURI(), httpServletResponse.getStatus()); }