tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cox, Charlie" <c...@cincom.com>
Subject RE: A simple filter question ..
Date Tue, 01 Jul 2003 12:25:07 GMT
change:
public void init(FilterConfig f) {}

to 
public void init(FilterConfig f) {setFilterConfig(f);}


from one of the filter samples for the m_filterConfig:
 /**
  * The filter configuration object we are associated with.  If this value
  * is null, this filter instance is not currently configured.
  */


Charlie

> -----Original Message-----
> From: Abid Ali Teepo [mailto:abid.ali.teepo@mogul.no]
> Sent: Tuesday, July 01, 2003 3:18 AM
> To: tomcat-user@jakarta.apache.org
> Subject: 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
> 

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


Mime
View raw message