Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why we have filters?

 
krishnama raju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didn't understand , why we have filters?

is there any special purpose for filters. all examples i have seen is just simple ones. i didn't get any knowledge from that.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One basic principle of modern computer architecture is separation of concerns.

By creating filters for particular common processes we make it easier to put together systems with parts that are known to work. You dont have to reinvent the wheel for every application.

Bill

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65339
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some example of filters that I use:
  • Check that there is a logged in user; redirect to login if not.
  • Add no-cache headers to the response.
  • Ensure that a Hibernate session is active.

  • That way, each and every servlet or JSP doesn't need to be concerned with these things that have to happen in every request.
     
    Ramakrishna Gutha
    Greenhorn
    Posts: 16
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    As bill said it is separation of particular concern.

    To demonstrate it properly, we have used a Tuckey's UrlRewrite filter. Our requirement is show the URL's in SEO friendy manner like www.nissan.com/Acura/MDX instead of www.nissan.com?make=Acura&model=MDX.

    The job of the filter is to convert the SEO friendly url to Server understandable URL. This made our pages get ranked more by Search Engines and improved the readability.

    Thanks
    GRK
     
    David Newton
    Author
    Rancher
    Posts: 12617
    IntelliJ IDE Ruby
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Compression is another common use for filters, i.e. sending back gzipped data to the client. There are a *lot* of reasonable uses for filters.
     
    Vijay Kumar
    Ranch Hand
    Posts: 260
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    It is one of the robust feature. You can intercepts requests and responses.

    Please see given URL

    Essentials of Filter.

    Regards,
    Vijay
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic