Example usage for javax.servlet.http HttpServletResponse setStatus

List of usage examples for javax.servlet.http HttpServletResponse setStatus

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse setStatus.

Prototype

public void setStatus(int sc);

Source Link

Document

Sets the status code for this response.

Usage

From source file:org.dataconservancy.ui.api.PersonController.java

/**
 * Handles get request with an id, this returns the serialized person
 * identified by the id. Not yet implemented.
 *
 * @param idpart//from w w w  . j  av a  2s.c  o m
 * @param mimeType
 * @param modifiedSince
 * @param request
 * @throws org.dataconservancy.ui.exceptions.BizPolicyException
 */
@RequestMapping(value = "/{idpart}", method = { RequestMethod.GET })
public void handlePersonGetRequest(@PathVariable String idpart,
        @RequestHeader(value = "Accept", required = false) String mimeType,
        @RequestHeader(value = "If-Modified-Since", required = false) @DateTimeFormat(iso = DATE_TIME) Date modifiedSince,
        HttpServletRequest request, HttpServletResponse resp) throws IOException, BizPolicyException {

    resp.setStatus(HttpStatus.SC_FORBIDDEN);
    resp.getWriter().println("Not yet implemented.");
}

From source file:com.moss.appkeep.server.HttpPublisher.java

private void completeWithError(String message, int code, HttpServletResponse response) throws IOException {
    response.setStatus(code);
    PrintWriter w = response.getWriter();
    w.write(message);/* w w  w.j a  v a  2  s. com*/
    w.close();
}

From source file:org.broadleafcommerce.admin.util.controllers.RemoveFileController.java

protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {

    DirectoryFileBean bean = (DirectoryFileBean) command;
    checkDirectory(bean.getAbsolutePath());

    response.setStatus(HttpServletResponse.SC_OK);
    return super.onSubmit(request, response, command, errors);
}

From source file:org.craftercms.cstudio.publishing.servlet.StatusMonitoringServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType(MimeTypeUtils.APPLICATION_JSON_VALUE);
    response.getWriter().println("{ status: \"" + statusMessage + "\" }");
    response.setStatus(HttpServletResponse.SC_OK);
}

From source file:org.nekorp.workflow.backend.controller.imp.EventoControllerImp.java

@Override
@RequestMapping(value = "/{idEvento}", method = RequestMethod.GET)
public @ResponseBody Evento getEvento(@PathVariable final Long idServicio, @PathVariable final Long idEvento,
        final HttpServletResponse response) {
    if (!idServicioValido(idServicio)) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
        return null;
    }//from w w  w  .  jav a  2 s . c o  m
    Evento respuesta = this.eventoDAO.consultar(idServicio, idEvento);
    if (respuesta == null) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
    }
    response.setHeader("Content-Type", "application/json;charset=UTF-8");
    return respuesta;
}

From source file:org.nekorp.workflow.backend.controller.imp.EventoControllerImp.java

@Override
@RequestMapping(value = "/{idEvento}", method = RequestMethod.POST)
public void actualizarEvento(@PathVariable final Long idServicio, @PathVariable final Long idEvento,
        @Valid @RequestBody final Evento dato, final HttpServletResponse response) {
    if (!idServicioValido(idServicio)) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
        return;// www  .j a  va  2s.c o  m
    }
    dato.setId(idEvento);
    if (eventoDAO.consultar(idServicio, idEvento) == null) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
    } else {
        eventoDAO.guardar(idServicio, dato);
    }
}

From source file:org.nekorp.workflow.backend.controller.imp.RegistroCostoControllerImp.java

@Override
@RequestMapping(value = "/{idRegistro}", method = RequestMethod.GET)
public @ResponseBody RegistroCosto getRegistro(@PathVariable final Long idServicio,
        @PathVariable final Long idRegistro, final HttpServletResponse response) {
    if (!idServicioValido(idServicio)) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
        return null;
    }/*from   www .jav  a 2  s  . co  m*/
    RegistroCosto respuesta = this.registroCostoDAO.consultar(idServicio, idRegistro);
    if (respuesta == null) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
    }
    response.setHeader("Content-Type", "application/json;charset=UTF-8");
    return respuesta;
}

From source file:org.nekorp.workflow.backend.controller.imp.RegistroCostoControllerImp.java

@Override
@RequestMapping(value = "/{idRegistro}", method = RequestMethod.POST)
public void actualizarRegistro(@PathVariable final Long idServicio, @PathVariable final Long idRegistro,
        @Valid @RequestBody final RegistroCosto datos, final HttpServletResponse response) {
    if (!idServicioValido(idServicio)) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
        return;/*from  ww  w .j  a v a  2s. c o m*/
    }
    datos.setId(idRegistro);
    if (registroCostoDAO.consultar(idServicio, idRegistro) == null) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
    } else {
        this.registroCostoDAO.guardar(idServicio, datos);
    }
}

From source file:org.nekorp.workflow.backend.controller.imp.UploadControllerImp.java

/**{@inheritDoc}*/
@Override/* w  w w  .j  av  a 2  s. co  m*/
@RequestMapping(value = "/imagenes/{rawBlobKey}", method = RequestMethod.GET)
public @ResponseBody void getImage(@PathVariable String rawBlobKey, HttpServletResponse response) {
    try {
        BlobKey blobKey = new BlobKey(rawBlobKey);
        blobstoreService.serve(blobKey, response);
    } catch (Exception e) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
    }
}

From source file:edu.cornell.library.scholars.webapp.controller.api.DistributeDataApiController.java

private void do500InternalServerError(String message, Exception e, HttpServletResponse resp)
        throws IOException {
    log.warn("500InternalServerError " + message, e);
    resp.setStatus(500);
    try {//www  .j a  va2s .c  o  m
        PrintWriter w = resp.getWriter();
        w.println(message);
        e.printStackTrace(w);
    } catch (IllegalStateException e1) {
        OutputStream os = resp.getOutputStream();
        os.write((message + "\n").getBytes());
        e.printStackTrace(new PrintStream(os));
    }

}