List of usage examples for javax.servlet.http HttpServletResponse setStatus
public void setStatus(int sc);
From source file:com.logsniffer.web.controller.sniffer.publisher.PublishersResourceController.java
@ExceptionHandler(value = Throwable.class) @ResponseBody//from w w w .j a v a 2 s . com public void handleAllExceptions(final Throwable ex, final HttpServletResponse response) throws IOException { logger.info("Failed to test event publishing", ex); response.setStatus(HttpStatus.CONFLICT.value()); response.setContentType(MediaType.TEXT_PLAIN_VALUE); final String stackTrace = ExceptionUtils.getStackTrace(ex); IOUtils.write(stackTrace, response.getOutputStream()); }
From source file:com.cisco.ctao.sparkapi.webhookserver.HttpEventProcessor.java
private void sendHttpResponse(final HttpServletResponse httpResponse) throws IOException { if (response != null) { httpResponse.setStatus(httpRSC); httpResponse.getWriter().println(response); } else {// w w w. j a v a 2 s. c o m httpResponse.setStatus(httpRSC); } httpResponse.setContentType("text/json;charset=utf-8"); }
From source file:de.perdoctus.synology.jdadapter.controller.JdAdapter.java
@RequestMapping(value = "/jdcheck.js", method = RequestMethod.GET) public void returnJdScript(final HttpServletResponse resp) throws IOException { LOG.info("Got Request from 'classic' click'n'load button."); resp.setStatus(200); resp.getWriter().println("jdownloader=true"); }
From source file:org.nekorp.workflow.backend.controller.imp.EventoControllerImp.java
@Override @RequestMapping(value = "/{idEvento}", method = RequestMethod.DELETE) public void borrarEvento(@PathVariable final Long idServicio, @PathVariable final Long idEvento, final HttpServletResponse response) { if (!idServicioValido(idServicio)) { response.setStatus(HttpStatus.NOT_FOUND.value()); return;/*from w w w . j a va 2s . c o m*/ } Evento dato = eventoDAO.consultar(idServicio, idEvento); if (dato == null) { //no hay nada que responder response.setStatus(HttpStatus.NO_CONTENT.value()); return; } eventoDAO.borrar(idServicio, dato); //se acepto la peticion de borrado, no quiere decir que sucede de inmediato. response.setStatus(HttpStatus.ACCEPTED.value()); }
From source file:org.nekorp.workflow.backend.controller.imp.RegistroCostoControllerImp.java
@Override @RequestMapping(value = "/{idRegistro}", method = RequestMethod.DELETE) public void borrarRegistro(@PathVariable final Long idServicio, @PathVariable final Long idRegistro, final HttpServletResponse response) { if (!idServicioValido(idServicio)) { response.setStatus(HttpStatus.NOT_FOUND.value()); return;/*from w w w. ja v a 2 s. c o m*/ } RegistroCosto dato = registroCostoDAO.consultar(idServicio, idRegistro); if (dato == null) { //no hay nada que responder response.setStatus(HttpStatus.NO_CONTENT.value()); return; } registroCostoDAO.borrar(idServicio, dato); //se acepto la peticion de borrado, no quiere decir que sucede de inmediato. response.setStatus(HttpStatus.ACCEPTED.value()); }
From source file:de.yaio.services.plantuml.server.controller.PlantumlController.java
@ExceptionHandler(value = { Exception.class, RuntimeException.class }) public void handleAllException(final HttpServletRequest request, final Exception e, final HttpServletResponse response) { LOGGER.info("Exception while running request:" + createRequestLogMessage(request), e); response.setStatus(SC_INTERNAL_SERVER_ERROR); try {/*from www.j a v a 2 s . c o m*/ response.getWriter().append("exception while converting plantuml"); } catch (IOException ex) { LOGGER.warn("exception while exceptionhandling", ex); } }
From source file:org.nekorp.workflow.backend.controller.imp.EventoControllerImp.java
@Override @RequestMapping(method = RequestMethod.GET) public @ResponseBody Page<Evento, Long> getEventos(@PathVariable final Long idServicio, @Valid @ModelAttribute final PaginationDataLong pagination, final HttpServletResponse response) { if (!idServicioValido(idServicio)) { response.setStatus(HttpStatus.NOT_FOUND.value()); return null; }// w w w . j av a 2 s.co m List<Evento> datos = eventoDAO.consultarTodos(idServicio, null, pagination); Page<Evento, Long> r = pagFactory.getPage(); r.setTipoItems("evento"); r.setLinkPaginaActual(armaUrl(idServicio, pagination.getSinceId(), pagination.getMaxResults())); if (pagination.hasNext()) { r.setLinkSiguientePagina(armaUrl(idServicio, pagination.getNextId(), pagination.getMaxResults())); r.setSiguienteItem(pagination.getNextId()); } r.setItems(datos); response.setHeader("Content-Type", "application/json;charset=UTF-8"); return r; }
From source file:org.nekorp.workflow.backend.controller.imp.RegistroCostoControllerImp.java
@Override @RequestMapping(method = RequestMethod.GET) public @ResponseBody Page<RegistroCosto, Long> getRegistros(@PathVariable final Long idServicio, @Valid @ModelAttribute final PaginationDataLong pagination, final HttpServletResponse response) { if (!idServicioValido(idServicio)) { response.setStatus(HttpStatus.NOT_FOUND.value()); return null; }//www. j ava 2 s . co m List<RegistroCosto> datos = registroCostoDAO.consultarTodos(idServicio, null, pagination); Page<RegistroCosto, Long> r = pagFactory.getPage(); r.setTipoItems("registroCosto"); r.setLinkPaginaActual(armaUrl(idServicio, pagination.getSinceId(), pagination.getMaxResults())); if (pagination.hasNext()) { r.setLinkSiguientePagina(armaUrl(idServicio, pagination.getNextId(), pagination.getMaxResults())); r.setSiguienteItem(pagination.getNextId()); } r.setItems(datos); response.setHeader("Content-Type", "application/json;charset=UTF-8"); return r; }
From source file:de.yaio.services.plantuml.server.controller.PlantumlController.java
@ExceptionHandler(value = { IOException.class }) public void handleCustomException(final HttpServletRequest request, final Exception e, final HttpServletResponse response) { LOGGER.info("IOException while running request:" + createRequestLogMessage(request), e); response.setStatus(SC_BAD_REQUEST); try {/*from www. j a va 2s .c o m*/ response.getWriter().append("exception while converting plantuml"); } catch (IOException ex) { LOGGER.warn("exception while exceptionhandling", ex); } }
From source file:eu.freme.common.exception.ExceptionHandlerService.java
public void writeExceptionToResponse(HttpServletRequest request, HttpServletResponse response, Throwable exception) throws IOException { ResponseEntity<String> responseEntity = handleError(request, exception); response.setStatus(responseEntity.getStatusCode().value()); response.getWriter().write(responseEntity.getBody()); response.flushBuffer();//from w w w . j a v a2 s . co m }