Example usage for javax.servlet.http HttpServletResponse setIntHeader

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

Introduction

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

Prototype

public void setIntHeader(String name, int value);

Source Link

Document

Sets a response header with the given name and integer value.

Usage

From source file:org.hyperic.lather.server.LatherServlet.java

private static void issueErrorResponse(HttpServletResponse resp, String errMsg) throws IOException {
    resp.setContentType("text/raw");
    resp.setIntHeader(LatherHTTPClient.HDR_ERROR, 1);
    resp.getOutputStream().print(errMsg);
}

From source file:net.ymate.framework.core.util.WebUtils.java

/**
 * @param response    HttpServletResponse
 * @param templateUrl JSP?URL//from  w  w w .  j  a  v a 2s.c  o m
 * @param time        
 * @param url         ?URL???
 * @return HeaderRefresh?url??Headertime???
 */
public static String doRedirectHeaderRefresh(HttpServletResponse response, String templateUrl, int time,
        String url) {
    if (StringUtils.isBlank(url)) {
        response.setIntHeader("REFRESH", time);
    } else {
        String _content = time + ";URL=" + url;
        response.setHeader("REFRESH", _content);
    }
    return templateUrl;
}

From source file:net.ymate.platform.webmvc.view.AbstractView.java

public IView addIntHeader(String name, int value) {
    HttpServletResponse _response = WebContext.getResponse();
    if (_response.containsHeader(name)) {
        _response.addIntHeader(name, value);
    } else {/*  w w w. ja  v  a  2  s.co m*/
        _response.setIntHeader(name, value);
    }
    return this;
}

From source file:com.netflix.spinnaker.gate.ratelimit.RateLimitingInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    // Hystrix et-al can return 429's, which we'll want to intercept to provide a reset header
    if (response.getStatus() == 429 && !response.getHeaderNames().contains(Rate.RESET_HEADER)) {
        response.setIntHeader(Rate.CAPACITY_HEADER, -1);
        response.setIntHeader(Rate.REMAINING_HEADER, 0);
        response.setDateHeader(Rate.RESET_HEADER, ZonedDateTime.now().plusSeconds(5).toEpochSecond());
        response.setHeader(Rate.LEARNING_HEADER, "false");
    }/*from w  w  w. j a  v  a2  s . c om*/
}

From source file:com.novartis.pcs.ontology.rest.servlet.GraphServlet.java

@Override
protected void doOptions(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String mediaType = getExpectedMediaType(request);

    if (mediaType != null) {
        // Preflight CORS support
        response.setStatus(HttpServletResponse.SC_OK);
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "GET");
        response.setIntHeader("Access-Control-Max-Age", 60 * 60 * 24);
        response.setContentType(mediaType + ";charset=utf-8");
        response.setContentLength(0);//from www . j  a v  a2 s .c o  m
    } else {
        response.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
        response.setContentLength(0);
    }
}

From source file:org.fireflow.webdesigner.servlet.handlers.GetProcessDefsHandler.java

protected void outputRawXml(String processXml, HttpServletResponse resp) throws ServletException, IOException {
    // contentType
    String encoding = Utils.findXmlCharset(processXml);
    //      resp.setContentType("text/xml charset="+encoding);
    resp.setContentType("text/xml");
    resp.setCharacterEncoding(encoding);

    // ???//  ww  w .  j  a  va2s  .  c om
    resp.setHeader("Pragma", "no-cache");
    resp.setHeader("Cache-Control", "no-cache");
    resp.setIntHeader("Expires", -1);

    byte[] byteArr = processXml.getBytes(encoding);

    OutputStream outStream = resp.getOutputStream();
    outStream.write(byteArr);
}

From source file:com.novartis.pcs.ontology.rest.servlet.SubtermsServlet.java

@Override
protected void doOptions(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String mediaType = getExpectedMediaType(request);

    if (MEDIA_TYPE_JSON.equals(mediaType)) {
        // Preflight CORS support
        response.setStatus(HttpServletResponse.SC_OK);
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "GET");
        response.setIntHeader("Access-Control-Max-Age", 60 * 60 * 24);
        response.setContentType(mediaType + ";charset=utf-8");
        response.setContentLength(0);/*from   w  w  w. j  av a  2s . c  om*/
    } else {
        response.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
        response.setContentLength(0);
    }
}

From source file:com.codename1.corsproxy.CORSProxy.java

@Override
protected void service(HttpServletRequest servletRequest, HttpServletResponse servletResponse)
        throws ServletException, IOException {
    super.service(servletRequest, servletResponse);
    if (servletResponse.getStatus() >= 300 && servletResponse.getStatus() < 400) {
        // XMLHTTPRequest automatically follows redirects.  We don't want that, so we'll
        // convert 3xx status to non-standard header that we will parse on the other side.
        servletResponse.setIntHeader("X-CN1-Status", servletResponse.getStatus());
        servletResponse.setStatus(200);//w w w.ja  va  2s.co m
    }
}

From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.Default.java

public void handleOptions(HttpServletRequest request, HttpServletResponse response) throws IOException {
    // Handle OPTIONS request for entire server
    // 9.2/*from ww w . j  a  va  2  s.  c  o m*/
    response.setIntHeader(HttpFields.__ContentLength, 0);
    response.setHeader(HttpFields.__Allow, _AllowString);
    response.flushBuffer();
}

From source file:com.codename1.corsproxy.CORSProxy.java

protected boolean doResponseRedirectOrNotModifiedLogic(HttpServletRequest servletRequest,
        HttpServletResponse servletResponse, HttpResponse proxyResponse, int statusCode)
        throws ServletException, IOException {

    // 304 needs special handling.  See:
    // http://www.ics.uci.edu/pub/ietf/http/rfc1945.html#Code304
    // We get a 304 whenever passed an 'If-Modified-Since'
    // header and the data on disk has not changed; server
    // responds w/ a 304 saying I'm not going to send the
    // body because the file has not changed.
    if (statusCode == HttpServletResponse.SC_NOT_MODIFIED) {
        servletResponse.setIntHeader(HttpHeaders.CONTENT_LENGTH, 0);
        servletResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
        return true;
    }//from  www .  j ava 2s  .c om
    return false;
}