Anyone know the difference between Tomcat Valve and Filter?

J

jacksuyu

Seems both could be hooked before servlet be called.

Does Valve work for more than just java servlet/jsp?

Thanks.
 
A

Adam Maass

Seems both could be hooked before servlet be called.

Does Valve work for more than just java servlet/jsp?

Similar in notion, but at different levels.

"Valve" is Tomcat's specific notion, and they get applied at a higher level
than anything in a specific webapp. Also, they work only in Tomcat.

"Filter" is a Servlet Specification notion and should work in any compliant
servlet container. They get applied at a lower level than all of Tomcat's
Valves.


-- Adam Maass
 
J

jacksuyu

Got it, thanks.
So if I want approach to work cross different application server, i
need to use Filter.
 
J

Juha Laiho

(e-mail address removed) said:
So if I want approach to work cross different application server, i
need to use Filter.

Yep. However, consider also the division between your application and the
application server. Think whether the feature you're planning is part of
your application, or is it rather a generic feature of the application
server, which could have uses in other applications as well.

This would be the correct criteria to decide between Valve and Filter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top