List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:com.belajar_filter.config.FilterBeanConfig.java
public static Filter myFilter() { Filter filter = new Filter() { private ServletContext context; @Override// w ww .java 2 s .c o m public void init(FilterConfig filterConfig) throws ServletException { log.debug("initiate general filter config"); this.context = filterConfig.getServletContext(); this.context.log("AuthenticationFilter initialized"); } @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain fc) throws IOException, ServletException { log.debug("execute do filter ... "); HttpServletResponse response = (HttpServletResponse) res; HttpServletRequest request = (HttpServletRequest) req; String getParam = request.getParameter("name"); String urlRequest = request.getRequestURI(); log.debug("intercept url request : " + urlRequest); log.debug("intercept param : " + getParam); if ("aji".equals(getParam)) { log.debug("is aji"); fc.doFilter(req, res); } else { log.debug("is not aji"); response.sendError(HttpServletResponse.SC_NOT_ACCEPTABLE); } } @Override public void destroy() { } }; return filter; }
From source file:MyServlet.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(request, response); response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("The filter got this message: " + filterConfig.getInitParameter("message")); }
From source file:com.acc.storefront.filters.btg.BTGSegmentFilter.java
@Override protected void doFilterInternal(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final FilterChain filterChain) throws ServletException, IOException { filterChain.doFilter(httpRequest, httpResponse); getBtgSegmentStrategy().evaluateSegment(httpRequest); }
From source file:MyServlet.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("In filter"); chain.doFilter(request, response); System.out.println("Leaving filter"); }
From source file:org.kmnet.com.fw.web.logging.mdc.MDCClearFilter.java
/** * Clears all the values from {@link MDC} after execution of all the filters is completed. * @param request {@link HttpServletRequest} * @param response {@link HttpServletResponse} * @param filterChain {@link FilterChain} * @throws ServletException If {@link ServletException} occurs further in the execution chain. * @throws IOException If IOException {@link IOException} occurs further in the execution chain. * @see org.springframework.web.filter.OncePerRequestFilter#doFilterInternal(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain) *//* w w w. j a v a2 s . co m*/ @Override protected final void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { try { filterChain.doFilter(request, response); } finally { MDC.clear(); } }
From source file:org.italiangrid.storm.webdav.server.LogRequestFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(request, response); SecurityContext ctxt = SecurityContextHolder.getContext(); HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; String resMsg = String.format("%s %s %s %d [user:<%s>, authorities:<%s>]", req.getRemoteAddr(), req.getMethod(), req.getRequestURI(), res.getStatus(), ctxt.getAuthentication().getName(), ctxt.getAuthentication().getAuthorities()); log.info(resMsg);//from w w w . ja v a 2s . c o m }
From source file:org.mayocat.jersey.JERSEY920WorkaroundServletFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try {/*w ww . j av a 2 s . c o m*/ chain.doFilter(request, response); } catch (Throwable t) { // We can add here exceptions we want to log on a case by case basis. if (t instanceof JsonMappingException) { logger.error("JSON mapping exception", t); } throw t; } }
From source file:com.orangeleap.common.security.SaveRequestFilter.java
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { OrangeLeapRequestLocal.setRequest(request); filterChain.doFilter(request, response); }
From source file:org.inspektr.error.web.ErrorLoggingFilter.java
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { try {/*from www .java 2s .c o m*/ filterChain.doFilter(request, response); } catch (ServletException e) { this.errorLogManager.recordError(e); throw e; } catch (IOException e) { this.errorLogManager.recordError(e); throw e; } catch (Throwable t) { this.errorLogManager.recordError(t); throw new ServletException(t); } }
From source file:org.jasig.portlet.maps.mvc.JsonContentTypeFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { response.setContentType("application/json"); filterChain.doFilter(request, response); }