blob: e14c2f77778acb67e7ca48ef6896ed2924873b9c [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>Filter</title>
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Filter";
}
}
catch(err) {
}
//-->
var methods = {"i0":18,"i1":6,"i2":18};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],16:["t5","Default Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-all.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../jakarta/servlet/DispatcherType.html" title="enum in jakarta.servlet"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../jakarta/servlet/FilterChain.html" title="interface in jakarta.servlet"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?jakarta/servlet/Filter.html" target="_top">Frames</a></li>
<li><a href="Filter.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">jakarta.servlet</div>
<h2 title="Interface Filter" class="title">Interface Filter</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><a href="../../jakarta/servlet/GenericFilter.html" title="class in jakarta.servlet">GenericFilter</a>, <a href="../../jakarta/servlet/http/HttpFilter.html" title="class in jakarta.servlet.http">HttpFilter</a></dd>
</dl>
<hr>
<br>
<pre>public interface <span class="typeNameLabel">Filter</span></pre>
<div class="block"><p>
A filter is an object that performs filtering tasks on either the request to a resource (a servlet or static
content), or on the response from a resource, or both.
</p>
<p>
Filters perform filtering in the <code>doFilter</code> method. Every Filter has access to a FilterConfig object from
which it can obtain its initialization parameters, and a reference to the ServletContext which it can use, for
example, to load resources needed for filtering tasks.
<p>
Filters are configured in the deployment descriptor of a web application.
<p>
Examples that have been identified for this design are:
<ol>
<li>Authentication Filters
<li>Logging and Auditing Filters
<li>Image conversion Filters
<li>Data compression Filters
<li>Encryption Filters
<li>Tokenizing Filters
<li>Filters that trigger resource access events
<li>XSL/T filters
<li>Mime-type chain Filter
</ol></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>Servlet 2.3</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t5" class="tableTab"><span><a href="javascript:show(16);">Default Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>default void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/servlet/Filter.html#destroy--">destroy</a></span>()</code>
<div class="block">
Called by the web container to indicate to a filter that it is being taken out of service.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/servlet/Filter.html#doFilter-jakarta.servlet.ServletRequest-jakarta.servlet.ServletResponse-jakarta.servlet.FilterChain-">doFilter</a></span>(<a href="../../jakarta/servlet/ServletRequest.html" title="interface in jakarta.servlet">ServletRequest</a>&nbsp;request,
<a href="../../jakarta/servlet/ServletResponse.html" title="interface in jakarta.servlet">ServletResponse</a>&nbsp;response,
<a href="../../jakarta/servlet/FilterChain.html" title="interface in jakarta.servlet">FilterChain</a>&nbsp;chain)</code>
<div class="block">The <code>doFilter</code> 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.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>default void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/servlet/Filter.html#init-jakarta.servlet.FilterConfig-">init</a></span>(<a href="../../jakarta/servlet/FilterConfig.html" title="interface in jakarta.servlet">FilterConfig</a>&nbsp;filterConfig)</code>
<div class="block">
Called by the web container to indicate to a filter that it is being placed into service.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="init-jakarta.servlet.FilterConfig-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>init</h4>
<pre>default&nbsp;void&nbsp;init(<a href="../../jakarta/servlet/FilterConfig.html" title="interface in jakarta.servlet">FilterConfig</a>&nbsp;filterConfig)
throws <a href="../../jakarta/servlet/ServletException.html" title="class in jakarta.servlet">ServletException</a></pre>
<div class="block"><p>
Called by the web container to indicate to a filter that it is being placed into service.
</p>
<p>
The servlet container calls the init method exactly once after instantiating the filter. The init method must
complete successfully before the filter is asked to do any filtering work.
</p>
<p>
The web container cannot place the filter into service if the init method either
</p>
<ol>
<li>Throws a ServletException
<li>Does not return within a time period defined by the web container
</ol></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>filterConfig</code> - a <code>FilterConfig</code> object containing the filter's configuration and initialization
parameters</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../jakarta/servlet/ServletException.html" title="class in jakarta.servlet">ServletException</a></code> - if an exception has occurred that interferes with the filter's normal operation</dd>
</dl>
</li>
</ul>
<a name="doFilter-jakarta.servlet.ServletRequest-jakarta.servlet.ServletResponse-jakarta.servlet.FilterChain-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>doFilter</h4>
<pre>void&nbsp;doFilter(<a href="../../jakarta/servlet/ServletRequest.html" title="interface in jakarta.servlet">ServletRequest</a>&nbsp;request,
<a href="../../jakarta/servlet/ServletResponse.html" title="interface in jakarta.servlet">ServletResponse</a>&nbsp;response,
<a href="../../jakarta/servlet/FilterChain.html" title="interface in jakarta.servlet">FilterChain</a>&nbsp;chain)
throws java.io.IOException,
<a href="../../jakarta/servlet/ServletException.html" title="class in jakarta.servlet">ServletException</a></pre>
<div class="block">The <code>doFilter</code> 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.
<p>
A typical implementation of this method would follow the following pattern:
<ol>
<li>Examine the request
<li>Optionally wrap the request object with a custom implementation to filter content or headers for input filtering
<li>Optionally wrap the response object with a custom implementation to filter content or headers for output
filtering
<li>
<ul>
<li><strong>Either</strong> invoke the next entity in the chain using the FilterChain object
(<code>chain.doFilter()</code>),
<li><strong>or</strong> not pass on the request/response pair to the next entity in the filter chain to block the
request processing
</ul>
<li>Directly set headers on the response after invocation of the next entity in the filter chain.
</ol></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>request</code> - the <code>ServletRequest</code> object contains the client's request</dd>
<dd><code>response</code> - the <code>ServletResponse</code> object contains the filter's response</dd>
<dd><code>chain</code> - the <code>FilterChain</code> for invoking the next filter or the resource</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an I/O related error has occurred during the processing</dd>
<dd><code><a href="../../jakarta/servlet/ServletException.html" title="class in jakarta.servlet">ServletException</a></code> - if an exception occurs that interferes with the filter's normal operation</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../jakarta/servlet/UnavailableException.html" title="class in jakarta.servlet"><code>UnavailableException</code></a></dd>
</dl>
</li>
</ul>
<a name="destroy--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>destroy</h4>
<pre>default&nbsp;void&nbsp;destroy()</pre>
<div class="block"><p>
Called by the web container to indicate to a filter that it is being taken out of service.
</p>
<p>
This method is only called once all threads within the filter's doFilter method have exited or after a timeout period
has passed. After the web container calls this method, it will not call the doFilter method again on this instance of
the filter.
</p>
<p>
This method gives the filter an opportunity to clean up any resources that are being held (for example, memory, file
handles, threads) and make sure that any persistent state is synchronized with the filter's current state in memory.
</p></div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-all.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../jakarta/servlet/DispatcherType.html" title="enum in jakarta.servlet"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../jakarta/servlet/FilterChain.html" title="interface in jakarta.servlet"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?jakarta/servlet/Filter.html" target="_top">Frames</a></li>
<li><a href="Filter.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>