You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Harakiri <ha...@yahoo.com> on 2006/08/01 21:56:54 UTC

Dynamically add Filter to webapp without declaring in web.xml

Hello,

is it possible to dynamically add a Filter for a web
app using the tomcat ? If so, is there an example how
to do this ?

OR is it possible to somehow init some webapps params
before the Filter is loaded ? I tried to use a Servlet
and used the <load-on-startup>1</load-on-startup>
within the web.xml - however the servlet is loaded
AFTER the filter is initialized (even when no web page
has been requested). Is there a better approach then
using a init servlet ?

The problem i currently have, is that im using a 3rd
party Security Filter which has "no knowledge" of my
application and relies on some Configuration (access
rights) which is initialized by my webapp. 

A good example for this problem would be if you have
dynamic Log4j configuration i.e. not using a log4j.xml
in the classpath but configuring it through the java
api. The Filter is already initialized when you do the
log4j initializion in the init servlet - thus making
it impossible to see/track an debug/error messages
from the filter at all.



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Dynamically add Filter to webapp without declaring in web.xml

Posted by Harakiri <ha...@yahoo.com>.
Thank you David judging by the description of "All
ServletContextListeners are notified of context
initialization BEFORE any filter" its exactly what i
need.

--- David Smith <dn...@cornell.edu> wrote:

> Depending on your version of tomcat,
> ServletContextListener may be an 
> excellent standard way to go.  There was a thread
> just a few days ago on 
> that.
> 
> --David
> 
> Harakiri wrote:
> 
> >Hello,
> >
> >is it possible to dynamically add a Filter for a
> web
> >app using the tomcat ? If so, is there an example
> how
> >to do this ?
> >
> >OR is it possible to somehow init some webapps
> params
> >before the Filter is loaded ? I tried to use a
> Servlet
> >and used the <load-on-startup>1</load-on-startup>
> >within the web.xml - however the servlet is loaded
> >AFTER the filter is initialized (even when no web
> page
> >has been requested). Is there a better approach
> then
> >using a init servlet ?
> >
> >The problem i currently have, is that im using a
> 3rd
> >party Security Filter which has "no knowledge" of
> my
> >application and relies on some Configuration
> (access
> >rights) which is initialized by my webapp. 
> >
> >A good example for this problem would be if you
> have
> >dynamic Log4j configuration i.e. not using a
> log4j.xml
> >in the classpath but configuring it through the
> java
> >api. The Filter is already initialized when you do
> the
> >log4j initializion in the init servlet - thus
> making
> >it impossible to see/track an debug/error messages
> >from the filter at all.
> >
> >
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> >http://mail.yahoo.com 
> >
>
>---------------------------------------------------------------------
> >To start a new topic, e-mail:
> users@tomcat.apache.org
> >To unsubscribe, e-mail:
> users-unsubscribe@tomcat.apache.org
> >For additional commands, e-mail:
> users-help@tomcat.apache.org
> >
> >  
> >
> 
> 
>
---------------------------------------------------------------------
> To start a new topic, e-mail:
> users@tomcat.apache.org
> To unsubscribe, e-mail:
> users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail:
> users-help@tomcat.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Dynamically add Filter to webapp without declaring in web.xml

Posted by David Smith <dn...@cornell.edu>.
Depending on your version of tomcat, ServletContextListener may be an 
excellent standard way to go.  There was a thread just a few days ago on 
that.

--David

Harakiri wrote:

>Hello,
>
>is it possible to dynamically add a Filter for a web
>app using the tomcat ? If so, is there an example how
>to do this ?
>
>OR is it possible to somehow init some webapps params
>before the Filter is loaded ? I tried to use a Servlet
>and used the <load-on-startup>1</load-on-startup>
>within the web.xml - however the servlet is loaded
>AFTER the filter is initialized (even when no web page
>has been requested). Is there a better approach then
>using a init servlet ?
>
>The problem i currently have, is that im using a 3rd
>party Security Filter which has "no knowledge" of my
>application and relies on some Configuration (access
>rights) which is initialized by my webapp. 
>
>A good example for this problem would be if you have
>dynamic Log4j configuration i.e. not using a log4j.xml
>in the classpath but configuring it through the java
>api. The Filter is already initialized when you do the
>log4j initializion in the init servlet - thus making
>it impossible to see/track an debug/error messages
>from the filter at all.
>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>  
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org