List of usage examples for javax.servlet.http HttpServletResponse setStatus
public void setStatus(int sc);
From source file:edu.unc.lib.dl.cdr.sword.server.servlets.ContainerServlet.java
@RequestMapping(value = { "/{pid}", "/{pid}/*" }, method = RequestMethod.PUT) public void replaceMetadataOrMetadataAndContent(HttpServletRequest req, HttpServletResponse resp) { try {/* ww w. ja v a2 s .co m*/ this.api.put(req, resp); } catch (Exception e) { log.error("Failed to update container " + req.getQueryString(), e); resp.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); } }
From source file:fr.gael.dhus.api.SearchController.java
@PreAuthorize("hasRole('ROLE_SEARCH')") @RequestMapping(value = "/search/suggest/{query}") public void suggestions(@PathVariable String query, HttpServletResponse res) throws IOException { List<String> suggestions = searchService.getSuggestions(query); res.setStatus(HttpServletResponse.SC_OK); res.setContentType("text/plain"); try (ServletOutputStream outputStream = res.getOutputStream()) { if (suggestions != null) { for (String suggestion : suggestions) { outputStream.println(suggestion); }//from ww w . j a v a 2 s . c o m } } }
From source file:net.prasenjit.auth.config.CustomAjaxAwareHandler.java
/** * {@inheritDoc}/*w w w .j a v a 2s. c om*/ */ @Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { if (checkIfAjaxRequest(request)) { response.setStatus(HttpStatus.OK.value()); } else { delegatedSuccessHandler.onAuthenticationSuccess(request, response, authentication); } }
From source file:net.prasenjit.auth.config.CustomAjaxAwareHandler.java
/** {@inheritDoc} */ @Override/*from w ww .ja va 2 s . c o m*/ public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { if (checkIfAjaxRequest(request)) { response.setStatus(HttpStatus.OK.value()); } else { delegatedLogoutSuccessHandler.onLogoutSuccess(request, response, authentication); } }
From source file:edu.unc.lib.dl.cdr.sword.server.servlets.ContainerServlet.java
@RequestMapping(value = { "/{pid}", "/{pid}/*" }, method = RequestMethod.POST) public void addMetadataOrMetadataAndContent(HttpServletRequest req, HttpServletResponse resp) { try {//from w ww . ja v a 2 s.co m this.api.post(req, resp); } catch (Exception e) { log.error("Failed to update container " + req.getQueryString(), e); resp.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); } }
From source file:de.thm.arsnova.controller.SocketController.java
@RequestMapping(method = RequestMethod.POST, value = "/assign") public void authorize(@RequestBody final Map<String, String> sessionMap, final HttpServletResponse response) { String socketid = sessionMap.get("session"); if (null == socketid) { LOGGER.debug("Expected property 'session' missing", socketid); response.setStatus(HttpStatus.BAD_REQUEST.value()); return;/*from w w w .j a v a 2 s . co m*/ } User u = userService.getCurrentUser(); if (null == u) { LOGGER.debug("Client {} requested to assign Websocket session but has not authenticated", socketid); response.setStatus(HttpStatus.FORBIDDEN.value()); return; } userService.putUser2SocketId(UUID.fromString(socketid), u); userSessionService.setSocketId(UUID.fromString(socketid)); response.setStatus(HttpStatus.NO_CONTENT.value()); }
From source file:com.googlecode.webutilities.servlets.WebProxyServlet.java
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (HttpOptions.METHOD_NAME.equals(req.getMethod())) { resp.setStatus(200); this.responseHeadersToInject.forEach(resp::setHeader); LOGGER.debug("Sending headers headers with status 200"); return;//from w w w . ja v a 2 s . co m } try { this.makeProxyRequest(req, resp); } catch (IOException ioe) { LOGGER.error("Failed to make proxy request", ioe); resp.setStatus(404); // Return 404 } }
From source file:edu.ucla.loni.pipeline.server.Upload.Uploaders.FileUploadServlet.java
/** * Handles HTTP POST Request/Response//from w w w . j a v a 2s . c o m * * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // set response status resp.setStatus(HttpServletResponse.SC_OK); // reset response message ResponseBuilder respBuilder = new ResponseBuilder(); // handle file upload handleFileUpload(req, respBuilder); // get response message String message = respBuilder.getRespMessage(); resp.getWriter().print(message); // flush response buffer resp.flushBuffer(); }
From source file:ch.rasc.extclassgenerator.ModelGenerator.java
public static void writeModel(HttpServletRequest request, HttpServletResponse response, ModelBean model, OutputConfig outputConfig) throws IOException { byte[] data = generateJavascript(model, outputConfig).getBytes(UTF8_CHARSET); String ifNoneMatch = request.getHeader("If-None-Match"); String etag = "\"0" + DigestUtils.md5DigestAsHex(data) + "\""; if (etag.equals(ifNoneMatch)) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return;/*from ww w .j av a 2s. com*/ } response.setContentType("application/javascript"); response.setCharacterEncoding(UTF8_CHARSET.name()); response.setContentLength(data.length); response.setHeader("ETag", etag); @SuppressWarnings("resource") ServletOutputStream out = response.getOutputStream(); out.write(data); out.flush(); }
From source file:org.attribyte.api.pubsub.impl.server.APIServlet.java
/** * Sends a JSON response.//w w w .ja va2 s .c o m * @param response The HTTP response. * @param responseNode The JSON node to send. * @throws IOException on write error. */ private void sendJSONResponse(HttpServletResponse response, ObjectNode responseNode) throws IOException { response.setStatus(HttpServletResponse.SC_OK); response.setContentType(JSON_CONTENT_TYPE); response.getOutputStream().write(responseNode.toString().getBytes(Charsets.UTF_8)); }