File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Tomcat 4.0 problem with Filter class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tomcat 4.0 problem with Filter class" Watch "Tomcat 4.0 problem with Filter class" New topic

Tomcat 4.0 problem with Filter class

Zhongwu Lin

Joined: Mar 06, 2001
Posts: 11
I can't compile the following file
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.ServletException;
public class SimpleFilter implements Filter
private FilterConfig filterConfig;
public void doFilter (ServletRequest request,
ServletResponse response,
FilterChain chain)
chain.doFilter (request, response);
} catch (IOException io) {
System.out.println ("IOException raised in SimpleFilter");
} catch (ServletException se) {
System.out.println ("ServletException raised in SimpleFilter");
public FilterConfig getFilterConfig()
return this.filterConfig;
public void setFilterConfig (FilterConfig filterConfig)
this.filterConfig = filterConfig;
I am using Jdk 1.4. and the servlet.jar ( from tomcat 4.0 ) is in the classpath.
I unjar servlet.jar and found out that in this jar file Filer class is defined as:
package javax.servlet;
// Imports
import javax.servlet.ServletException;
import javax.servlet.FilterConfig;
import javax.servlet.FilterChain;
import javax.servlet.ServletResponse;
import javax.servlet.ServletRequest;
public abstract interface Filter {
// Methods
void destroy();
void doFilter(ServletRequest p0, ServletResponse p1,
FilterChain p2) throws IOException, ServletException;
void init(FilterConfig p0) throws ServletException;
From servlet spec. we don't have to implement

we only need to implement

My question:
What do I need to do in order to write servlet using new features in spect 2.3 such as Filter to run under tomcat?

I agree. Here's the link:
subject: Tomcat 4.0 problem with Filter class
jQuery in Action, 3rd edition