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.chtijbug.drools.platform.web.security.Http403AuthenticationFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    response.setStatus(SC_FORBIDDEN);
    response.getWriter().write(exception.getMessage());

}

From source file:edu.cornell.mannlib.vitro.webapp.controller.SparqlQueryBuilderServlet.java

private void doNoModelInContext(HttpServletRequest request, HttpServletResponse res) {
    try {//from  w  ww .  jav a  2s.  com
        res.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED);
        ServletOutputStream sos = res.getOutputStream();
        sos.println("<html><body>this service is not supporeted by the current "
                + "webapp configuration. A jena model is required in the servlet context.</body></html>");
    } catch (IOException e) {
        log.error("Could not write to ServletOutputStream");
    }
}

From source file:com.sg.rest.security.components.SgAccessDeniedHandler.java

@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e)
        throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_FORBIDDEN);

    AccessDenied dto = new AccessDenied();
    LOGGER.error("Authorization failed " + dto.getEventRef().getId() + ": ", e);

    response.setContentType(CustomMediaTypes.APPLICATION_JSON_UTF8.getMediatype().toString());
    jacksonObjectMapper.writeValue(response.getWriter(), dto);
}

From source file:no.smint.anthropos.authentication.TokenEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    //response.sendRedirect("/api/login");
}

From source file:com.seyren.core.security.UnauthorizedEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    response.setContentType((MediaType.APPLICATION_JSON.toString()));
    response.setCharacterEncoding("UTF-8");
    response.getWriter().write(authException.getMessage());
}

From source file:de.hska.ld.core.config.security.AjaxAuthenticationFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {

    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}

From source file:no.dusken.momus.authentication.TokenEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}

From source file:com.ibm.ws.lars.rest.ErrorHandler.java

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    response.setStatus(500);
    response.setContentType(MediaType.APPLICATION_JSON);
    PrintWriter printWriter = response.getWriter();
    JsonGenerator frontPageJsonGenerator = new JsonFactory().createGenerator(printWriter);
    frontPageJsonGenerator.setPrettyPrinter(new DefaultPrettyPrinter());

    frontPageJsonGenerator.writeStartObject();
    frontPageJsonGenerator.writeStringField("message",
            "Internal server error, please contact the server administrator");
    frontPageJsonGenerator.writeNumberField("statusCode", response.getStatus());
    frontPageJsonGenerator.writeEndObject();

    frontPageJsonGenerator.flush();//from   w  w w. ja va 2  s .co m
    frontPageJsonGenerator.close();
}

From source file:fi.helsinki.opintoni.security.AuthFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);

    PrintWriter writer = response.getWriter();
    writer.write(exception.getMessage());
    writer.flush();/*from w  w  w.j  a  v  a 2s .  c  o m*/
}