aspose file tools*
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tomcat 4.0 problem with Filter class" Watch "Tomcat 4.0 problem with Filter class" New topic
Author

Tomcat 4.0 problem with Filter class

Zhongwu Lin
Greenhorn

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 java.io.IOException;
import javax.servlet.ServletException;
public class SimpleFilter implements Filter
{
private FilterConfig filterConfig;
public void doFilter (ServletRequest request,
ServletResponse response,
FilterChain chain)
{
try
{
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 java.io.IOException;
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
destroy()
init()

we only need to implement
doFilter()
getFilterConfig()
setFilterConfig()

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?

Regards
 
 
subject: Tomcat 4.0 problem with Filter class