List of usage examples for javax.servlet ServletRequest removeAttribute
public void removeAttribute(String name);
From source file:org.opensolaris.opengrok.web.PageConfig.java
/** * Cleanup all allocated resources (if any) from the instance attached to * the given request./*from www.j a va2s .co m*/ * * @param sr request to check, cleanup. Ignored if {@code null}. * @see PageConfig#get(HttpServletRequest) */ public static void cleanup(ServletRequest sr) { if (sr == null) { return; } PageConfig cfg = (PageConfig) sr.getAttribute(ATTR_NAME); if (cfg == null) { return; } sr.removeAttribute(ATTR_NAME); cfg.env = null; cfg.req = null; if (cfg.eftarReader != null) { cfg.eftarReader.close(); } ProjectHelper.cleanup(); }
From source file:org.springframework.security.web.FilterChainProxy.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { boolean clearContext = request.getAttribute(FILTER_APPLIED) == null; if (clearContext) { try {//from ww w . j a va2s . c o m request.setAttribute(FILTER_APPLIED, Boolean.TRUE); doFilterInternal(request, response, chain); } finally { SecurityContextHolder.clearContext(); request.removeAttribute(FILTER_APPLIED); } } else { doFilterInternal(request, response, chain); } }
From source file:org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.java
/** * {@inheritDoc}/*from w ww .jav a 2s .c o m*/ * * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, * javax.servlet.FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { ServletRequest filteredRequest = request; // This filter works only for HTTP requests, because they are the only ones with a session. if (request instanceof HttpServletRequest && !Boolean.valueOf((String) request.getAttribute(ATTRIBUTE_APPLIED))) { // Get the saved request, if any (returns null if not applicable) SavedRequest savedRequest = getSavedRequest((HttpServletRequest) request); // Merge the new and the saved request filteredRequest = new SavedRequestWrapper((HttpServletRequest) request, savedRequest); filteredRequest.setAttribute(ATTRIBUTE_APPLIED, "true"); } // Forward the request chain.doFilter(filteredRequest, response); // Allow multiple calls to this filter as long as they are not nested. filteredRequest.removeAttribute(ATTRIBUTE_APPLIED); }
From source file:org.xwiki.portlet.controller.DispatchFilter.java
/** * {@inheritDoc}//from w ww . j a va 2 s.c om * * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (request instanceof HttpServletRequest && !Boolean.valueOf((String) request.getAttribute(ATTRIBUTE_APPLIED))) { HttpServletRequest httpRequest = (HttpServletRequest) request; RequestType requestType = (RequestType) request.getAttribute(DispatchPortlet.ATTRIBUTE_REQUEST_TYPE); if (requestType != null) { HttpServletResponse httpResponse = (HttpServletResponse) response; // Prevent nested calls to this filter. request.setAttribute(ATTRIBUTE_APPLIED, "true"); switch (requestType) { case ACTION: doAction(httpRequest, httpResponse, chain); break; case RENDER: doRender(httpRequest, httpResponse, chain); break; case RESOURCE: doResource(httpRequest, httpResponse, chain); break; default: // We should never get here. break; } // Allow multiple calls to this filter, as long as they are not nested. We need this because we // transform redirects into dispatches and thus a request can be dispatched multiple times, but these // dispatches shouldn't be nested. request.removeAttribute(ATTRIBUTE_APPLIED); return; } } chain.doFilter(request, response); }