List of usage examples for javax.servlet.http HttpServletResponse addHeader
public void addHeader(String name, String value);
From source file:com.frameworkx.PoweredByPlugin.java
/** * When the request is initially received, add the header * * @param request/*from w ww . java 2s . c o m*/ * @param response */ public void onRequestReceived(final HttpServletRequest request, final HttpServletResponse response) { response.addHeader("X-Powered-By", this.headerValue); }
From source file:com.spring.common.handlerInterceptor.java
/** * /*w w w . j av a 2 s . c om*/ * @param request * @param response * @param handler * @return * @throws Exception */ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { response.addHeader("Access-Control-Allow-Origin", "*"); /*String url = request.getRequestURI(); return url.contains("display");*/ System.out.println(session.getAttribute("user")); //false?? return true; }
From source file:com.bstek.dorado.view.resolver.SkinFileResolver.java
@Override protected ModelAndView doHandleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { response.addHeader(HttpConstants.CACHE_CONTROL, HttpConstants.MAX_AGE + WebConfigure.getLong("web.resourceMaxAge", 3600)); return super.doHandleRequest(request, response); }
From source file:com.rest.api.CORSFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { response.addHeader("Access-Control-Allow-Origin", "*"); if (request.getHeader("Access-Control-Request-Method") != null && "OPTIONS".equals(request.getMethod())) { response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE"); response.addHeader("Access-Control-Allow-Headers", "Content-Type"); response.addHeader("Access-Control-Max-Age", "1"); }/*from www . j av a 2 s .co m*/ filterChain.doFilter(request, response); }
From source file:com.chevrier.legiondao.config.CorsFilter.java
@Override protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException { httpServletResponse.addHeader("Access-Control-Allow-Origin", "*"); httpServletResponse.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); httpServletResponse.addHeader("Access-Control-Allow-Headers", "origin, content-type, accept,x-req"); filterChain.doFilter(httpServletRequest, httpServletResponse); }
From source file:com.uniquesoft.uidl.servlet.UploadServlet.java
/** * Writes a response to the client.// w ww . ja va 2 s.co m */ protected static void renderMessage(HttpServletResponse response, String message, String contentType) throws IOException { response.addHeader("Cache-Control", "no-cache"); response.setContentType(contentType + "; charset=GB2312"); response.setCharacterEncoding("GB2312"); PrintWriter out = response.getWriter(); out.print(message); System.out.println("=======>" + message); out.flush(); out.close(); }
From source file:com.counter.counter.api.AuthenticationEntryPoint.java
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authEx) throws IOException, ServletException { response.addHeader("WWW-Authenticate", "Basic realm=" + getRealmName()); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); PrintWriter writer = response.getWriter(); writer.println("HTTP Status 401 - " + authEx.getMessage()); }
From source file:eu.creatingfuture.propeller.webLoader.servlets.WebRequestServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.addHeader("Access-Control-Allow-Origin", "*"); String getUrl = req.getParameter("get"); if (getUrl == null) { resp.sendError(400);//ww w . ja v a 2 s . co m return; } logger.info(getUrl); URL url; HttpURLConnection connection = null; try { url = new URL(getUrl); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setUseCaches(false); resp.setContentType(connection.getContentType()); resp.setContentLengthLong(connection.getContentLengthLong()); logger.log(Level.INFO, "Content length: {0} response code: {1} content type: {2}", new Object[] { connection.getContentLengthLong(), connection.getResponseCode(), connection.getContentType() }); resp.setStatus(connection.getResponseCode()); IOUtils.copy(connection.getInputStream(), resp.getOutputStream()); } catch (IOException ioe) { resp.sendError(500, ioe.getMessage()); } finally { if (connection != null) { connection.disconnect(); } } }
From source file:com.dp2345.filter.AccessDeniedFilter.java
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) servletResponse; // PoweredBy dp2345.com response.addHeader(new String(base64.decode("UG93ZXJlZEJ5"), "utf-8"), new String(base64.decode("ZHAyMzQ1LmNvbQ=="), "utf-8")); response.sendError(HttpServletResponse.SC_FORBIDDEN, ERROR_MESSAGE); }
From source file:org.cloudfoundry.identity.api.web.CorsFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { response.addHeader("Access-Control-Allow-Origin", "*"); if (request.getHeader("Access-Control-Request-Method") != null && "OPTIONS".equals(request.getMethod())) ;// w w w. j a va2 s .c o m { // CORS "pre-flight" request response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE"); response.addHeader("Access-Control-Allow-Headers", "Authorization"); response.addHeader("Access-Control-Max-Age", "1728000"); } filterChain.doFilter(request, response); }