List of usage examples for javax.servlet.http HttpServletResponse setHeader
public void setHeader(String name, String value);
From source file:org.spee.sbweb.domain.SimpleCORSFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { // TODO Auto-generated method stub HttpServletResponse response = (HttpServletResponse) resp; response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); chain.doFilter(req, resp);/*from w w w. ja v a2s . c o m*/ }
From source file:things.view.rest.SimpleCorsFilter.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, PUT"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "content-type,x-requested-with"); chain.doFilter(req, res);//from w ww. j ava2s .co m }
From source file:trycb.util.CorsFilter.java
@Override 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-Headers", "Origin, X-Requested-With, Content-Type, Accept"); chain.doFilter(req, res);/* www.j a v a 2 s.co m*/ }
From source file:co.utb.softeng.contactsapp.config.CORSInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { response.setHeader("Access-Control-Allow-Credentials", "true"); response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "Origin, x-requested-with, Content-Type, Accept"); return true;//from www. j av a2 s. c o m }
From source file:com.sg.rest.filters.CorsFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { // TODO Auto-generated method stub HttpServletResponse response = (HttpServletResponse) resp; 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, Authorization"); chain.doFilter(req, resp);/* w w w.j a v a 2s . c o m*/ }
From source file:com.thinkberg.moxo.dav.OptionsHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setHeader("DAV", "1, 2"); String path = request.getPathInfo(); StringBuffer options = new StringBuffer(); FileObject object = getResourceManager().getFileObject(path); if (object.exists()) { options.append("OPTIONS, GET, HEAD, POST, DELETE, TRACE, COPY, MOVE, LOCK, UNLOCK, PROPFIND"); if (FileType.FOLDER.equals(object.getType())) { options.append(", PUT"); }//from w ww . j av a2 s . co m } else { options.append("OPTIONS, MKCOL, PUT, LOCK"); } response.setHeader("Allow", options.toString()); // see: http://www-128.ibm.com/developerworks/rational/library/2089.html response.setHeader("MS-Author-Via", "DAV"); }
From source file:com.webapp.controller.SampleController.java
/** * This shows how to create a simple MVC endpoint. * @param m/*w ww . java 2s . c o m*/ * @return */ @RequestMapping("home") public String loadHomePage(HttpServletRequest request, final HttpServletResponse response, Model model) { response.setHeader("Cache-Control", "max-age=0, no-cache, no-store"); // Get the title of the application in the request's locale model.addAttribute("title", webapp.getMessage("webapp.subtitle", null, request.getLocale())); return "home"; }
From source file:com.thinkberg.webdav.OptionsHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setHeader("DAV", "1, 2"); String path = request.getPathInfo(); StringBuffer options = new StringBuffer(); FileObject object = VFSBackend.resolveFile(path); if (object.exists()) { options.append("OPTIONS, GET, HEAD, POST, DELETE, TRACE, COPY, MOVE, LOCK, UNLOCK, PROPFIND"); if (FileType.FOLDER.equals(object.getType())) { options.append(", PUT"); }// www . j a va 2 s . c o m } else { options.append("OPTIONS, MKCOL, PUT, LOCK"); } response.setHeader("Allow", options.toString()); // see: http://www-128.ibm.com/developerworks/rational/library/2089.html response.setHeader("MS-Author-Via", "DAV"); }
From source file:com.thoughtworks.go.agent.testhelper.AgentBinariesServlet.java
protected void doHead(HttpServletRequest request, HttpServletResponse response) { try {/*from w ww .j av a 2 s .c o m*/ response.setHeader("Content-MD5", resource.getMd5()); final String extraPropertiesHeaderValue = fakeGoServer.getExtraPropertiesHeaderValue(); if (extraPropertiesHeaderValue != null) { response.setHeader(AGENT_EXTRA_PROPERTIES_HEADER, Base64.encodeBase64String(extraPropertiesHeaderValue.getBytes(StandardCharsets.UTF_8))); } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:dtu.ds.warnme.ws.rest.json.HelloWorldRestService.java
@ExceptionHandler(Exception.class) public @ResponseBody String handleException(Exception ex, HttpServletRequest request, HttpServletResponse response) throws IOException { response.setHeader("Content-Type", "application/json"); response.setStatus(HttpServletResponse.SC_NOT_FOUND); return ex.getMessage(); }