List of usage examples for javax.servlet.http HttpServletResponse setStatus
public void setStatus(int sc);
From source file:com.qwazr.webapps.exception.WebappException.java
@Override public void sendQuietly(HttpServletResponse response) { try {//from ww w .j a v a 2s.c o m String contentType = response.getContentType(); response.setStatus(error.status); if (contentType != null) { if (contentType.startsWith("application/xml")) { sendQuietlyXML(response); return; } else if (contentType.startsWith("application/json")) { sendQuietlyJSON(response); return; } } sendQuietlyHTML(response); } catch (IOException e) { if (logger.isWarnEnabled()) logger.warn(e.getMessage(), e); } }
From source file:gsn.http.GMLHandler.java
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setStatus(HttpServletResponse.SC_OK); String reqName = request.getParameter("name"); String reqGroup = request.getParameter("group"); String reqUsername = request.getParameter("username"); String reqPassword = request.getParameter("password"); response.getWriter().write(buildOutput(reqName, reqGroup, reqUsername, reqPassword)); }
From source file:com.sentinel.rest.handlers.AuthSuccessHandler.java
@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { LOG.trace("Method: onAuthenticationSuccess called."); response.setStatus(HttpServletResponse.SC_OK); UserDetails userdetails = (UserDetails) authentication.getPrincipal(); LOG.info(userdetails.getUsername() + " got is connected "); PrintWriter writer = response.getWriter(); mapper.writeValue(writer, null);//from w w w . jav a 2 s .c o m writer.flush(); LOG.trace("Method: onAuthenticationSuccess finished."); }
From source file:org.smigo.species.vernacular.VernacularController.java
@PreAuthorize("isAuthenticated()") @RequestMapping(value = "/rest/vernacular/{id:\\d+}", method = RequestMethod.PUT) @ResponseBody/*from ww w .java 2 s.c o m*/ public Object updateVernacular(@Valid @RequestBody Vernacular vernacular, BindingResult result, @PathVariable int id, @AuthenticationPrincipal AuthenticatedUser user, Locale locale, HttpServletResponse response) { log.info("Updating vernacular:" + vernacular); if (result.hasErrors()) { response.setStatus(HttpStatus.UNPROCESSABLE_ENTITY.value()); return result.getAllErrors(); } Review review = vernacularHandler.updateVernacular(id, vernacular, user, locale); if (review == Review.MODERATOR) { response.setStatus(HttpStatus.ACCEPTED.value()); } return null; }
From source file:com.vmware.bdd.rest.advice.DefaultExceptionHandler.java
/** * convert BddException to properly REST Message * @param ex BddException raised from server code * @param response access to the HTTP response * @return REST Message to the client//from w w w .ja v a 2 s . c o m */ @ExceptionHandler(BddException.class) @ResponseBody public BddErrorMessage processBddException(BddException ex, HttpServletResponse response) { //if you want to change the response code, don't forget to add mapping inside serengeti-errcode.properties response.setStatus(getHttpErrorCode(ex.getFullErrorId())); return ServerErrorMessages.fromException(ex); }
From source file:com.nec.harvest.security.HarvestLoginUrlAuthenticationEntryPoint.java
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { if (isPreflight(request)) { response.setStatus(HttpServletResponse.SC_NO_CONTENT); } else if (isRestRequest(request)) { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); } else {//w ww . jav a 2s . co m super.commence(request, response, authException); } }
From source file:io.kamax.mxisd.controller.DefaultExceptionHandler.java
@ExceptionHandler(RemoteLoginException.class) public String handle(HttpServletRequest request, HttpServletResponse response, RemoteLoginException e) { if (e.getErrorBodyMsgResp() != null) { response.setStatus(e.getStatus()); log.info("Request {} {} - Error {}: {}", request.getMethod(), request.getRequestURL(), e.getErrorCode(), e.getError());/* ww w. j a v a 2 s. co m*/ return gson.toJson(e.getErrorBodyMsgResp()); } return handleGeneric(request, response, e); }
From source file:net.thewaffleshop.passwd.security.AuthenticationHandler.java
/** * Unsuccessful login; send error/*from w ww . j a va2 s. co m*/ * * @param request * @param response * @param exception * @throws IOException * @throws ServletException */ @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { String msg = exception.getMessage(); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json"); response.getWriter().write("{\"success\": false, \"msg\": \"" + StringEscapeUtils.escapeJson(msg) + "\"}"); }
From source file:org.magnum.dataup.MyVideoController.java
@RequestMapping(value = "/video/{id}/data", method = RequestMethod.POST) public @ResponseBody VideoStatus setVideoData(@PathVariable("id") long id, @RequestParam("data") MultipartFile videoData, HttpServletResponse response) { if (id == 0 || videoData == null) { response.setStatus(404); return (new VideoStatus(VideoState.READY)); }/*from w w w. ja v a2 s .co m*/ Video v = videos.get(id); if (v == null) { response.setStatus(404); return (new VideoStatus(VideoState.READY)); } try { VideoFileManager vfm = VideoFileManager.get(); vfm.saveVideoData(v, videoData.getInputStream()); } catch (Exception e) { e.printStackTrace(); } return (new VideoStatus(VideoState.READY)); }
From source file:be.bittich.quote.security.UnauthorizedEntryPoint.java
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { String respJSON = jsonifyMap(ImmutableMap.of("error", "Access denied.")); response.setStatus(401); response.setCharacterEncoding(ENCODING_UTF8); response.getWriter().printf(respJSON).flush(); response.getWriter().close();//from w ww.ja v a 2 s .c o m }