Thanks Will, 

The filter servlet is only for logging checking and parameter init. I
would have like to learn more about (J2EE) pattern using filter and
listener servlet.

The problem about the filter servlet is that doFilter() do not throws
exception, so we must catch everything in doFilter. So that is why I was
hiding everything in back of it. It can be hard to debug that way.

Regards, 

Etienne


-----Original Message-----
From: Will Hartung [mailto:willh@xxxxxxxxx] 
Sent: February 21, 2003 12:36 PM
To: Tomcat Users List
Subject: Re: Servlet filter and listerner best practices

> From: "Etienne" <etienno@xxxxxxxxxxxx>
> Sent: Friday, February 21, 2003 3:47 AM
> Subject: Servlet filter and listerner best practices


> Hi all,
>
> I am looking for some "best practices" for servlet filter (and servlet
> listener). These are quite new (servlet 2.3). I am using a servlet
> filter on some of my jsp page, but I would need a detail example of
the
> best way to implement it.

It kind of all depends on what your Filter needs to do. Passive filters
(like, say, a Logging Filter) can be quite different from something like
a
GZip filter, which needs to really muck about with the request and
streams
and what not.

> I am not sure how to catch exception in the servlet filter without
hiding
> everything in the back on it.

Pretty standard exception technique here. If you catch an exception that
you
don't want to deal with, simply throw it again and let something else
higher
up take care of it. Even better, don't catch exceptions that you can't
handle at all. The old proclamation of "Don't test for something you
can't
handle" rings loudly here.

Perhaps some more detail about your situation would be helpful.

> Is there a more precise way (with some reg ex?) to associate a filter
with
pages?

I dunno, the filter specification is pretty specific, perhaps too
specific
meaning that for lots of disparate pages, you'll have lots of entries in
the
web.xml. Perhaps if you could organize your pages in a hierarchy so you
could simply put the filter on a parent directory part of the path would
help reduce the load on the web.xml file.

Regards,

Will Hartung
(willh@xxxxxxxxx)





---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: tomcat-user-help@xxxxxxxxxxxxxxxxxx



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: tomcat-user-help@xxxxxxxxxxxxxxxxxx

Reply via email to