List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:com.sun.socialsite.web.filters.CustomizedPageCachingFilter.java
@Override protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws Exception { if (enabled) { response.reset();//from w ww . ja va 2 s.c om //response.setHeader("Cache-Control", "max-age=0, must-revalidate"); super.doFilter(request, response, chain); } else { chain.doFilter(request, response); } }
From source file:com.acc.storefront.filters.btg.AbstractBtgFilter.java
@Override public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws IOException, ServletException { if (getSiteConfigService().getBoolean(CONFIG_BTG_ENABLED, false)) { final AbstractBTGRuleDataEvent<Serializable> event = getEvent(request); publishEvent(event);/* w ww .ja v a2 s . co m*/ try { chain.doFilter(request, response); } finally { if (isRequestScoped() && event != null) { publishEvent(getCleanupEvent(event)); } } } else // BTG is disabled, just run the filter chain { chain.doFilter(request, response); } }
From source file:com.siriusit.spezg.multilib.jsf.login.UserPopulatorFilter.java
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { UserBean userBean = (UserBean) applicationContext.getBean("userBean"); if (userBean.getUser() == null && isAuthenticated()) { String username = getUsernameFromAuthentication(); userBean.populateUser(username); }//ww w . ja v a2s. c o m filterChain.doFilter(servletRequest, servletResponse); }
From source file:org.atomserver.utils.acegi.ConfigurableFilterChainProxy.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (useFilters) { super.doFilter(request, response, chain); } else {/*w ww . ja v a 2s . c o m*/ if (!wasWarned) { log.warn("WARNING: NOT USING Acegi ServletFilters"); wasWarned = true; } chain.doFilter(request, response); } }
From source file:com.erudika.para.utils.filters.ErrorFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) { ErrorWrapperResponse wrapped = new ErrorWrapperResponse((HttpServletResponse) response); try {/*from w ww . j a v a 2 s . c o m*/ chain.doFilter(request, wrapped); int status = wrapped.getStatus(); if (status >= 400) { setErrorAttributes(request, status, wrapped.getMessage()); } } catch (Throwable ex) { rethrow(ex); } response.flushBuffer(); } else { chain.doFilter(request, response); } }
From source file:com.autentia.tnt.filter.HibernateSessionRequestFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try {//from w ww . ja v a2 s . c o m log.debug("Starting a database transaction"); sf.openSession(); sf.getCurrentSession().beginTransaction(); // Call the next filter (continue request processing) chain.doFilter(request, response); // Commit and cleanup log.debug("Committing the database transaction"); if (sf.getCurrentSession().getTransaction().isActive()) { sf.getCurrentSession().getTransaction().commit(); } sf.getCurrentSession().close(); } catch (StaleObjectStateException staleEx) { log.error("This interceptor does not implement optimistic concurrency control!"); log.error("Your application will not work until you add compensation actions!"); // Rollback, close everything, possibly compensate for any permanent changes // during the conversation, and finally restart business conversation. Maybe // give the user of the application a chance to merge some of his work with // fresh data... what you do here depends on your applications design. throw staleEx; } catch (Exception ex) { // Rollback only log.error("Error en doFilter ", ex); try { if (sf.getCurrentSession().getTransaction().isActive()) { log.debug("Trying to rollback database transaction after exception"); sf.getCurrentSession().getTransaction().rollback(); } } catch (Exception rbEx) { log.error("Could not rollback transaction after exception!", rbEx); } // Let others handle it... maybe another interceptor for exceptions? throw new ServletException(ex); } }
From source file:edu.cornell.mannlib.vitro.webapp.filters.WebappDaoFactorySDBPrep.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (request.getAttribute("WebappDaoFactorySDBPrep.setup") != null) { // don't run multiple times filterChain.doFilter(request, response); return;/* ww w. j a va2 s . co m*/ } for (Pattern skipPattern : skipPatterns) { Matcher match = skipPattern.matcher(((HttpServletRequest) request).getRequestURI()); if (match.matches()) { log.debug("request matched a skipPattern, skipping VitroRequestPrep"); filterChain.doFilter(request, response); return; } } OntModelSelector oms = ModelContext.getUnionOntModelSelector(_ctx); OntModelSelector baseOms = ModelContext.getBaseOntModelSelector(_ctx); String defaultNamespace = (String) _ctx.getAttribute("defaultNamespace"); WebappDaoFactory wadf = null; VitroRequest vreq = new VitroRequest((HttpServletRequest) request); List<String> langs = new ArrayList<String>(); log.debug("Accept-Language: " + vreq.getHeader("Accept-Language")); Enumeration<Locale> locs = vreq.getLocales(); while (locs.hasMoreElements()) { Locale locale = locs.nextElement(); langs.add(locale.toString().replace("_", "-")); } if (langs.isEmpty()) { langs.add("en"); } WebappDaoFactoryConfig config = new WebappDaoFactoryConfig(); config.setDefaultNamespace(defaultNamespace); config.setPreferredLanguages(langs); RDFServiceFactory factory = RDFServiceUtils.getRDFServiceFactory(_ctx); //RDFService rdfService = factory.getRDFService(); RDFService unfilteredRDFService = factory.getShortTermRDFService(); RDFService rdfService = null; if (!"false" .equals(ConfigurationProperties.getBean(vreq).getProperty("RDFService.languageFilter", "true"))) { rdfService = new LanguageFilteringRDFService(unfilteredRDFService, langs); } else { rdfService = unfilteredRDFService; } Dataset dataset = new RDFServiceDataset(rdfService); wadf = new WebappDaoFactorySDB(rdfService, oms, config); WebappDaoFactory assertions = new WebappDaoFactorySDB(rdfService, baseOms, config, SDBDatasetMode.ASSERTIONS_ONLY); vreq.setRDFService(rdfService); vreq.setUnfilteredRDFService(unfilteredRDFService); vreq.setWebappDaoFactory(wadf); vreq.setAssertionsWebappDaoFactory(assertions); vreq.setFullWebappDaoFactory(wadf); vreq.setUnfilteredWebappDaoFactory( new WebappDaoFactorySDB(rdfService, ModelContext.getUnionOntModelSelector(_ctx))); vreq.setDataset(dataset); vreq.setOntModelSelector(baseOms); vreq.setJenaOntModel(ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, dataset.getDefaultModel())); request.setAttribute("WebappDaoFactorySDBPrep.setup", 1); try { filterChain.doFilter(request, response); return; } finally { if (wadf != null) { wadf.close(); } } }
From source file:com.sun.socialsite.web.rest.core.XrdsFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; if ("application/xrds+xml".equals(request.getHeader("Accepts"))) { RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/jsps/xrds.jsp"); rd.include(req, res);//from w w w .j a v a 2 s . c o m } else { chain.doFilter(req, res); } }
From source file:com.zyeeda.framework.web.CharacterEncodingFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (this.encoding != null && (this.forceEncoding || StringUtils.isBlank(req.getCharacterEncoding()))) { req.setCharacterEncoding(encoding); if (this.forceEncoding) { res.setCharacterEncoding(this.encoding); }/*from w w w.ja v a2 s . c o m*/ } chain.doFilter(req, res); }
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) *///from www .ja v a2 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); }