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:com.dangdang.ddframe.job.console.security.WwwAuthFilter.java

private void needAuthenticate(final HttpServletRequest request, final HttpServletResponse response) {
    response.setStatus(401);
    response.setHeader("Cache-Control", "no-store");
    response.setDateHeader("Expires", 0);
    response.setHeader("WWW-authenticate", AUTH_PREFIX + "Realm=\"Elastic Job Console Auth\"");
}

From source file:net.sf.j2ep.responsehandlers.BasicResponseHandler.java

/**
 * Sets the headers, writes the stream and sets the status code.
 * /*from  w  w w.j  a  va 2s  .  co  m*/
 * @see net.sf.j2ep.model.ResponseHandler#process(javax.servlet.http.HttpServletResponse)
 */
public void process(HttpServletResponse response) throws IOException {
    setHeaders(response);
    response.setStatus(getStatusCode());
    sendStreamToClient(response);
}

From source file:de.iew.web.controllers.MessageBundleController.java

@ExceptionHandler(value = Exception.class)
public void onException(Exception e, HttpServletResponse response) {
    response.setStatus(404);
    if (log.isErrorEnabled()) {
        log.error("Fehler beim Rendern eines MessageBundle.", e);
    }//from   w  w w  .j  av  a2s . co  m
}

From source file:org.esigate.servlet.impl.ResponseSender.java

void sendHeaders(HttpResponse httpResponse, IncomingRequest httpRequest, HttpServletResponse response) {
    response.setStatus(httpResponse.getStatusLine().getStatusCode());
    for (Header header : httpResponse.getAllHeaders()) {
        String name = header.getName();
        String value = header.getValue();
        response.addHeader(name, value);
    }//from  w ww . j  a va 2  s .c o m

    // Copy new cookies
    Cookie[] newCookies = httpRequest.getNewCookies();

    for (int i = 0; i < newCookies.length; i++) {
        response.addHeader("Set-Cookie", CookieUtil.encodeCookie(newCookies[i]));
    }
    HttpEntity httpEntity = httpResponse.getEntity();
    if (httpEntity != null) {
        long contentLength = httpEntity.getContentLength();
        if (contentLength > -1 && contentLength < Integer.MAX_VALUE) {
            response.setContentLength((int) contentLength);
        }
        Header contentType = httpEntity.getContentType();
        if (contentType != null) {
            response.setContentType(contentType.getValue());
        }
        Header contentEncoding = httpEntity.getContentEncoding();
        if (contentEncoding != null) {
            response.setHeader(contentEncoding.getName(), contentEncoding.getValue());
        }
    }
}

From source file:com.thoughtworks.go.spark.SparkPreFilter.java

private void render404(HttpServletResponse response) throws IOException {
    response.setStatus(404);
    response.setCharacterEncoding("utf-8");
    response.setContentType("text/plain");
    response.getOutputStream().println("The url you are trying to reach appears to be incorrect.");
}

From source file:com.tamnd.app.config.security.AuthSuccess.java

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_OK);
}

From source file:com.tamnd2.basicwebapp.security.AuthFailure.java

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

From source file:es.ucm.fdi.dalgs.rest.security.RestLogoutSuccessHandler.java

@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_OK);
}

From source file:pdfjsannotator.controller.AnnotationController.java

@RequestMapping(value = "/api/annotations", method = RequestMethod.DELETE)
public void delete(HttpServletResponse response) {
    response.setStatus(204);
}

From source file:org.chtijbug.drools.platform.web.security.Http200AuthenticationSuccessHandler.java

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_OK);
    response.getWriter().write(authentication.getName());
}