Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat 4.0 problem with Filter class  RSS feed

 
Zhongwu Lin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!