Example usage for javax.servlet.http HttpServletResponse addHeader

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

Introduction

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

Prototype

public void addHeader(String name, String value);

Source Link

Document

Adds a response header with the given name and value.

Usage

From source file:com.ebay.pulsar.analytics.security.spring.PlainTextBasicAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\"");
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    PrintWriter writer = response.getWriter();
    writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage());

}

From source file:com.tianjunwei.download.DownLoadController.java

@RequestMapping(value = { "/download" }, method = { RequestMethod.GET })
public void download(HttpServletResponse response) throws IOException {
    response.setContentType("application/octet-stream");
    response.addHeader("Content-Disposition", "attachment; filename=download.txt");
    OutputStream outputStream = response.getOutputStream();
    outputStream.write("sdsdfs".getBytes());
    outputStream.close();//  w  w w .jav  a2s .c om
}

From source file:de.thm.arsnova.web.CorsFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    response.addHeader("Access-Control-Allow-Credentials", "true");
    response.addHeader("Access-Control-Allow-Methods", "GET");
    response.addHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With");

    if (request.getHeader("origin") != null) {
        response.addHeader("Access-Control-Allow-Origin", request.getHeader("origin"));
    }/*from  w w  w .  j  ava 2s. co m*/

    filterChain.doFilter(request, response);
}

From source file:org.awesomeagile.webapp.security.AwesomeAgileAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.addHeader("WWW-Authenticate", "AwesomeAgile");
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage());
}

From source file:com.twinsoft.convertigo.engine.enums.HeaderName.java

public void addHeader(HttpServletResponse response, String headerValue) {
    response.addHeader(value, headerValue);
}

From source file:org.openwms.client.application.CorsDecorator.java

/**
 * @see org.springframework.web.filter.OncePerRequestFilter#doFilterInternal(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain)
 */// w  w w  .j  a v  a  2 s  .  co  m
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    response.addHeader("Access-Control-Allow-Origin", "*");
    response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
    response.addHeader("Access-Control-Allow-Headers", "Content-Type, Auth-Token");
    response.addHeader("Access-Control-Max-Age", "1800");
    filterChain.doFilter(request, response);
}

From source file:com.econcept.init.AppAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse pResponse,
        AuthenticationException authException) throws IOException, ServletException {
    pResponse.addHeader("WWW-Authenticate", "xBasic realm=\"" + getRealmName() + "\"");
    pResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage());
}

From source file:ro.allevo.fintpws.security.ApiAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.addHeader("Access-Control-Allow-Origin", "null");
    response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\"");
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    PrintWriter writer = response.getWriter();
    writer.println(/*w ww. j  av a 2  s  .  co  m*/
            "Here : HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage());
}

From source file:pdl.web.filter.JsonBasicAuthenticationEP.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\"");
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    PrintWriter writer = response.getWriter();
    writer.printf("Error(%s) - %s", HttpServletResponse.SC_UNAUTHORIZED, "Bad credentials");
}

From source file:com.iblsoft.iwxxm.webservice.ws.ValidationServlet.java

private void addCorsResponseHeaders(HttpServletResponse response) {
    if (!this.allowOriginHeader.isEmpty()) {
        response.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, this.allowOriginHeader);
        response.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "GET, POST,OPTIONS");
        response.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, HttpHeaders.CONTENT_TYPE);
    }/*from   w  w  w  .ja  va  2 s  .c o  m*/
}