Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: What's the different between a Valve and Filter?

...

  1. Wiki Markup
    \[#Q1 I am unable to compile my JSP!\]
  2. Wiki Markup
    \[#Q2 I can't get servlets to work under /servlet/\*!\]
  3. Wiki Markup
    \[#Q3 Why is the invoker evil?\]
  4. Wiki Markup
    \[#Q4 How to I get Tomcat's version number?\]
  5. Wiki Markup
    \[#Q5 Tomcat eats 100% of the CPU!\]
  6. Wiki Markup
    \[#Q6 How do I get a customized error page?\]
  7. Wiki Markup
    \[#Q7 Should I use the LE version?\]
  8. Wiki Markup
    \[#Q8 How do I configure Tomcat to NOT to store the sessions during shutdown?\]
  9. Wiki Markup
    \[#Q9 How do I disable tag pooling?\]
  10. Wiki Markup
    \[#Q10 Is there a DTD for server.xml?\]
  11. Wiki Markup
    \[#Q11 How do I change the welcome file? ( I want to show index.jsp instead of index.html)\]
  12. Wiki Markup
    \[#Q12 How do I enable/disable directory listings?\]
  13. Wiki Markup
    \[#Q13 How do I use symbolic links with jars?\]
  14. Wiki Markup
    \[#Q14 How do I change the name of the file in the download Save-As dialog from a servlet? (or jsp)\]
  15. Wiki Markup
    \[#Q15 Is tag pooling broken? It doesn't call release!\]
  16. Wiki Markup
    \[#Q16 Why do I get java.lang.IllegalStateException ?\]
  17. Wiki Markup
    \[#Q17 How do I make a scheduled event on Tomcat?\]
  18. Wiki Markup
    \[#Q18 What is Element "web-app" does not allow "servlet" here?\]
  19. Wiki Markup
    \[#Q19 How do open a file for reading in my webapp?\]
  20. Wiki Markup
    \[#Q20 Can I run tomcat with the JRE, or do I need the full JDK?\]
  21. Wiki Markup
    \[#Q21 Is tomcat an EJB server? Can I use EJBs with tomcat?\]
  22. Wiki Markup
    \[#Q22 Can I access Tomcat's JNDI provider from outside tomcat?\]
  23. Wiki Markup
    \[#Q23 Who uses tomcat in production?\]
  24. Wiki Markup
    \[#Q24 I'm getting java.lang.ThreadDeath exceptions when reloading my webapp.\]
  25. Wiki Markup
    \[#Q25 Help! Even though I run shutdown.sh (or shutdown.bat), Tomcat does not stop!\]
  26. Wiki Markup
    \[#Q26 How do I debug JSP errors in the Admin web application?\]
  27. Wiki Markup
    \[#Q27 What order do webapps start (or How can I change startup order)?\]
  28. Wiki Markup
    \[#Q28 What's the different between a Valve and Filter?
    \\

Answers

I am unable to compile my JSP!

...

There is no expected startup order. Neither the Servlet spec nor Tomcat define one. You can't rely on the apps starting in any particular order.

What's the different between a Valve and Filter?

A Filter lives in the webapp space and it's behavior is defined by the Servlet spec. It will work across all Servlet containers.

A Valve can do everything a Filter can do but is Tomcat specific, and potentially not portable across Tomcat versions. A Valve can be executed earlier in the lifecycle of a request, access Tomcat internals, and do other "interesting" decorations to your webapp in the chance you cannot change your deployed webapp.

If you can achieve the desired functionality with a Filter, it is the preferred way to go.