List of usage examples for javax.servlet.http HttpServletResponse setHeader
public void setHeader(String name, String value);
From source file:eu.freme.broker.tools.CORSFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) res; response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "x-requested-with, content-type"); chain.doFilter(req, res);/* ww w . java 2s .com*/ }
From source file:com.acmemotors.rest.web.CORSFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) res; response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "GET"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); chain.doFilter(req, res);/* www . j a v a2 s . c o m*/ }
From source file:hr.foi.sis.filters.CorsFilter.java
@Override public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) sr1; response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With," + " Content-Range, Content-Disposition, Content-Type, Authorization, X-CSRF-TOKEN"); if ("OPTIONS".equalsIgnoreCase(((HttpServletRequest) sr).getMethod())) { response.setStatus(HttpServletResponse.SC_OK); } else {// w ww. j a v a 2s .c om fc.doFilter(sr, sr1); } }
From source file:uk.ac.ebi.eva.server.CORSResponseFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) res; response.setHeader("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, accept"); response.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS"); response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Max-Age", "3600"); chain.doFilter(req, res);/* ww w.ja v a 2 s .co m*/ }
From source file:com.emaxcore.emaxdata.common.web.Servlets.java
/** * ?? If-None-Match Header, Etag?./*from ww w . j a va2 s . com*/ * * Etag, checkIfNoneMatchfalse, 304 not modify status. * * @param etag ETag. */ public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) { String headerValue = request.getHeader(HttpHeaders.IF_NONE_MATCH); if (headerValue != null) { boolean conditionSatisfied = false; if (!"*".equals(headerValue)) { StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ","); while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { String currentToken = commaTokenizer.nextToken(); if (currentToken.trim().equals(etag)) { conditionSatisfied = true; } } } else { conditionSatisfied = true; } if (conditionSatisfied) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader(HttpHeaders.ETAG, etag); return false; } } return true; }
From source file:org.killbill.billing.plugin.analytics.http.BaseServlet.java
protected void setCrossSiteScriptingHeaders(final HttpServletResponse resp) { resp.setHeader("Access-Control-Allow-Origin", "*"); resp.setHeader("Access-Control-Request-Method", "GET"); resp.setHeader("Access-Control-Allow-Headers", "accept, origin, content-type"); }
From source file:ch.wisv.areafiftylan.security.CORSFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); response.setHeader("Access-Control-Allow-Credentials", "true"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT, PATCH"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, remember-me"); chain.doFilter(req, res);/*w w w . j ava 2 s .c om*/ }
From source file:hr.foi.rsc.filters.CorsFilter.java
@Override public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) sr1; response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Range, Content-Disposition, Content-Type, Authorization, X-CSRF-TOKEN"); if ("OPTIONS".equalsIgnoreCase(((HttpServletRequest) sr).getMethod())) { response.setStatus(HttpServletResponse.SC_OK); } else {/*from w w w.ja v a 2 s. c om*/ fc.doFilter(sr, sr1); } }
From source file:com.indeed.imhotep.web.ParseController.java
@RequestMapping("/parse") @ResponseBody//from w ww . ja v a2s.c o m protected SelectStatement handleParse(@RequestParam("q") String query, @RequestParam(value = "json", required = false, defaultValue = "") String json, HttpServletResponse resp) throws IOException { resp.setHeader("Access-Control-Allow-Origin", "*"); try { final IQLStatement parsedQuery = StatementParser.parse(query, metadata); if (!(parsedQuery instanceof SelectStatement)) { throw new RuntimeException("The query is not recognized as a select statement: " + query); } return (SelectStatement) parsedQuery; } catch (Throwable e) { QueryServlet.handleError(resp, !Strings.isNullOrEmpty(json), e, false, false); return null; } }
From source file:com.devicehive.auth.rest.SimpleCORSFilter.java
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { final HttpServletResponse resp = (HttpServletResponse) servletResponse; resp.setHeader("Access-Control-Allow-Credentials", "true"); resp.setHeader("Access-Control-Allow-Origin", "*"); resp.setHeader("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PUT, DELETE, HEAD"); resp.setHeader("Access-Control-Max-Age", "0"); resp.setHeader("Access-Control-Allow-Headers", "Origin, Authorization, Accept, Content-Type, Auth-DeviceID, Auth-DeviceKey"); filterChain.doFilter(servletRequest, resp); }