• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why we have filters?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Greenhorn
    Posts: 16
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
     
    Author
    Posts: 12617
    IntelliJ IDE Ruby
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    Ranch Hand
    Posts: 260
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic