tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Abid Ali Teepo" <>
Subject A filter for authentication
Date Mon, 30 Jun 2003 15:09:53 GMT


I am trying to make a filter that will redirect all request that don't have a autheticated
attribute set, to be redirected to the login page.

Somehow my filter does not work properly even though it still is a very basic implementation
does nothing besides a few system out prints.

The only confirmation i get that this filter is in fact loaded into tocat, is that during
startup my constructor is called. I know that since the system out call writes to the console.

The filter is supposed to take all request to the site since the url-pattern is set to /*

Here is the code for the filter :

public class BidFilter implements Filter
  private FilterConfig filterConfig;

	public BidFilter() {System.out.println("Filter Constructor");}

  public void init(FilterConfig f) {}
  public void doFilter (ServletRequest request, ServletResponse response,
        FilterChain chain)

      System.out.print ("Within Bid Filter ... ");
      System.out.println ("Filtering the Request ...");

      chain.doFilter (request, response);

      System.out.print ("Within Bid Filter ... ");
      System.out.println ("Filtering the Response ...");

    } catch (IOException io) {
      System.out.println ("IOException raised in BidFilter");
    } catch (ServletException se) {
      System.out.println ("ServletException raised in BidFilter");

  public FilterConfig getFilterConfig()
    return this.filterConfig;

  public void setFilterConfig (FilterConfig filterConfig)
    this.filterConfig = filterConfig;
  public void destroy() { }

And here is the web.xml file for the filter :

?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "">

    <display-name>Filter Request</display-name>
    <description>The Secure Server</description>



Any help would be very appreciated


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message