You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Abid Ali Teepo <ab...@mogul.no> on 2003/07/01 09:17:44 UTC

A simple filter question ..

> Hi
> 
> 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 that
> does nothing besides a few system out prints.
> 
> The only confirmation i get that this filter is in fact loaded into tomcat, 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)
>   {
> 
>     try
>     {
>       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" "http://java.sun.com/dtd/web-app_2_3.dtd">
> 
> <web-app>
>     <display-name>Filter Request</display-name>
>     <description>The Secure Server</description>
>     
>     <filter>
> 		<filter-name>BidFilter</filter-name>
> 		<filter-class>Bid.BidFilter</filter-class>
> 	</filter>
> 	
> 	<filter-mapping>
> 		<filter-name>BidFilter</filter-name>
> 		<url-pattern>/*</url-pattern>
> 	</filter-mapping>  
> 
>  	<session-config>
>         	<session-timeout>1</session-timeout>
>   	  </session-config>
> 
>   	<welcome-file-list>
>   		<welcome-file>index.html</welcome-file>
>   	</welcome-file-list>
>   	
> </web-app>
> 
> 
> Any help would be very appreciated
> 
> regards
> Abid
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org