Tabnine Logo
Filter.doFilter
Code IndexAdd Tabnine to your IDE (free)

How to use
doFilter
method
in
javax.servlet.Filter

Best Java code snippets using javax.servlet.Filter.doFilter (Showing top 20 results out of 1,503)

origin: spring-projects/spring-framework

/**
 * Actually invoke the delegate Filter with the given request and response.
 * @param delegate the delegate Filter
 * @param request the current HTTP request
 * @param response the current HTTP response
 * @param filterChain the current FilterChain
 * @throws ServletException if thrown by the Filter
 * @throws IOException if thrown by the Filter
 */
protected void invokeDelegate(
    Filter delegate, ServletRequest request, ServletResponse response, FilterChain filterChain)
    throws ServletException, IOException {
  delegate.doFilter(request, response, filterChain);
}
origin: jenkinsci/jenkins

  public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
    if(position==filters.length) {
      // reached to the end
      chain.doFilter(request,response);
    } else {
      // call next
      filters[position++].doFilter(request,response,this);
    }
  }
}.doFilter(request,response);
origin: jersey/jersey

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
  wrappedFilter.doFilter(request, response, chain);
}
origin: org.springframework/spring-web

/**
 * Actually invoke the delegate Filter with the given request and response.
 * @param delegate the delegate Filter
 * @param request the current HTTP request
 * @param response the current HTTP response
 * @param filterChain the current FilterChain
 * @throws ServletException if thrown by the Filter
 * @throws IOException if thrown by the Filter
 */
protected void invokeDelegate(
    Filter delegate, ServletRequest request, ServletResponse response, FilterChain filterChain)
    throws ServletException, IOException {
  delegate.doFilter(request, response, filterChain);
}
origin: spring-projects/spring-framework

  @Override
  public void doFilter(final ServletRequest request, final ServletResponse response)
      throws IOException, ServletException {
    if (this.currentPosition == this.additionalFilters.size()) {
      this.originalChain.doFilter(request, response);
    }
    else {
      this.currentPosition++;
      Filter nextFilter = this.additionalFilters.get(this.currentPosition - 1);
      nextFilter.doFilter(request, response, this);
    }
  }
}
origin: jenkinsci/jenkins

  public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
    if(itr.hasNext()) {
      // call next
      itr.next().doFilter(request, response, this);
    } else {
      // reached to the end
      chain.doFilter(request,response);
    }
  }
}.doFilter(request,response);
origin: apache/incubator-druid

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
  throws IOException, ServletException
{
 // If there's already an auth result, then we have authenticated already, skip this.
 if (request.getAttribute(AuthConfig.DRUID_AUTHENTICATION_RESULT) != null) {
  chain.doFilter(request, response);
 } else {
  delegate.doFilter(request, response, chain);
 }
}
origin: spring-projects/spring-framework

/**
 * Pass the call on to the Filter/Servlet.
 */
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws ServletException, IOException {
  if (this.filter != null) {
    this.filter.doFilter(request, response, this.nextFilterChain);
  }
  else {
    Assert.state(this.servlet != null, "Neither a Filter not a Servlet set");
    this.servlet.service(request, response);
  }
}
origin: spring-projects/spring-framework

/**
 * Invoke registered {@link Filter Filters} and/or {@link Servlet} also saving the
 * request and response.
 */
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
  Assert.notNull(request, "Request must not be null");
  Assert.notNull(response, "Response must not be null");
  Assert.state(this.request == null, "This FilterChain has already been called!");
  if (this.iterator == null) {
    this.iterator = this.filters.iterator();
  }
  if (this.iterator.hasNext()) {
    Filter nextFilter = this.iterator.next();
    nextFilter.doFilter(request, response, this);
  }
  this.request = request;
  this.response = response;
}
origin: jenkinsci/jenkins

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  LOGGER.entering(HudsonFilter.class.getName(), "doFilter");
  // this is not the best place to do it, but doing it here makes the patch smaller.
  ((HttpServletResponse)response).setHeader("X-Content-Type-Options", "nosniff");
  // to deal with concurrency, we need to capture the object.
  Filter f = filter;
  if(f==null) {
    // Hudson is starting up.
    chain.doFilter(request,response);
  } else {
    f.doFilter(request,response,chain);
  }
}
origin: org.springframework/spring-web

  @Override
  public void doFilter(final ServletRequest request, final ServletResponse response)
      throws IOException, ServletException {
    if (this.currentPosition == this.additionalFilters.size()) {
      this.originalChain.doFilter(request, response);
    }
    else {
      this.currentPosition++;
      Filter nextFilter = this.additionalFilters.get(this.currentPosition - 1);
      nextFilter.doFilter(request, response, this);
    }
  }
}
origin: SonarSource/sonarqube

@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
 if (iterator == null) {
  iterator = filters.iterator();
 }
 if (iterator.hasNext()) {
  iterator.next().doFilter(request, response, this);
 } else {
  chain.doFilter(request, response);
 }
}
origin: openzipkin/brave

@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
  FilterChain filterChain) throws IOException, ServletException {
 servletRequest.setAttribute(Call.Factory.class.getName(), callFactory);
 delegate.doFilter(servletRequest, servletResponse, filterChain);
}
origin: apache/shiro

public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
  if (chain.hasNext()) {
    Filter filter = chain.next();
    filter.doFilter(request, response, this);
  } else if (!originalCalled) {
    originalCalled = true;
    originalChain.doFilter(request, response);
  }
}
origin: spring-projects/spring-framework

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
    throws IOException, ServletException {
  HttpServletRequest httpRequest = (HttpServletRequest) request;
  String requestPath = urlPathHelper.getPathWithinApplication(httpRequest);
  if (matches(requestPath)) {
    this.delegate.doFilter(request, response, filterChain);
  }
  else {
    filterChain.doFilter(request, response);
  }
}
origin: spring-projects/spring-framework

/**
 * Pass the call on to the Filter/Servlet.
 */
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws ServletException, IOException {
  if (this.filter != null) {
    this.filter.doFilter(request, response, this.nextFilterChain);
  }
  else {
    Assert.state(this.servlet != null, "Neither a Filter not a Servlet set");
    this.servlet.service(request, response);
  }
}
origin: spring-projects/spring-framework

/**
 * Invoke registered {@link Filter Filters} and/or {@link Servlet} also saving the
 * request and response.
 */
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
  Assert.notNull(request, "Request must not be null");
  Assert.notNull(response, "Response must not be null");
  Assert.state(this.request == null, "This FilterChain has already been called!");
  if (this.iterator == null) {
    this.iterator = this.filters.iterator();
  }
  if (this.iterator.hasNext()) {
    Filter nextFilter = this.iterator.next();
    nextFilter.doFilter(request, response, this);
  }
  this.request = request;
  this.response = response;
}
origin: perwendel/spark

@Override
public void doHandle(
    String target,
    Request baseRequest,
    HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException {
  HttpRequestWrapper wrapper = new HttpRequestWrapper(request);
  filter.doFilter(wrapper, response, null);
  if (wrapper.notConsumed()) {
    baseRequest.setHandled(false);
  } else {
    baseRequest.setHandled(true);
  }
}
origin: spring-projects/spring-security

@Test
public void httpBasicUnauthorizedOnDefault() throws Exception {
  // @formatter:off
  loadContext("<http>\n" +
    "		<intercept-url pattern=\"/**\" access=\"hasRole('USER')\" />\n" +
    "		<http-basic />\n" +
    "	</http>\n" +
    "\n" +
    "	<authentication-manager />");
  // @formatter:on
  this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain);
  assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_UNAUTHORIZED);
  assertThat(this.response.getHeader("WWW-Authenticate")).isEqualTo("Basic realm=\"Realm\"");
}
origin: stagemonitor/stagemonitor

@Test
public void testDontProfileStagemonitorServlet() throws Exception {
  Filter filter = new HttpRequestMonitorFilter();
  final CallStackElement total = Profiler.activateProfiling("total");
  filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), new MockFilterChain());
  Profiler.stop();
  assertEquals(0, total.getChildren().size());
}
javax.servletFilterdoFilter

Javadoc

The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. The FilterChain passed in to this method allows the Filter to pass on the request and response to the next entity in the chain.

A typical implementation of this method would follow the following pattern:

  1. Examine the request
  2. Optionally wrap the request object with a custom implementation to filter content or headers for input filtering
  3. Optionally wrap the response object with a custom implementation to filter content or headers for output filtering
    • Either invoke the next entity in the chain using the FilterChain object (chain.doFilter()),
    • or not pass on the request/response pair to the next entity in the filter chain to block the request processing
  4. Directly set headers on the response after invocation of the next entity in the filter chain.

Popular methods of Filter

  • init
    Called by the web container to indicate to a filter that it is being placed into service. The servle
  • destroy
    Called by the web container to indicate to a filter that it is being taken out of service. This meth
  • <init>

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • onRequestPermissionsResult (Fragment)
  • runOnUiThread (Activity)
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now