use of filters

Discussions

Web tier: servlets, JSP, Web frameworks: use of filters

  1. use of filters (3 messages)

    Hi Can someone tell me the use of filters in a J2EE app. i think whatever work the filter does can also be done using a servlet...so just wanted to know why do we still have filters. Any real life application example where filters are used ? Thanks, Moin

    Threaded Messages (3)

  2. Re: use of filters[ Go to top ]

    Http filters are used for preprocessing and post-processing in a web app. For example, you can use http filters for authentication and authorization purposes. You can validate every access to each resource of your Web app implementing a filter which checks if the user has enough permission to access the specified resource. Check this out: http://java.sun.com/blueprints/corej2eepatterns/Patterns/InterceptingFilter.html
  3. Re: use of filters[ Go to top ]

    Thanks for the above post.... But i still do feel that the functionality described in the article above can as well be done using a servlet. I can do authentication or limiting acces using a servlet as well...i can also do the logging too. Since both the servlet and the filters get passed with the same ServletRequest object...i get a feeling that if i am building a web app, i can totally do away with filters. plz correct me if i am incorrect. Thanks, Moin
  4. Re: use of filters[ Go to top ]

    See for example filter's collection in JSOS: http://www.servletsuite.com/filters.htm