• 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

Filter vs Base Servlet

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this has been asked before, just point me to the link.

If you had a choice between using a Servlet Filter for web app security or using a Base Servlet that you extend on all your Servlets, which would you prefer and why?
 
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
I use a filter for its flexibility. It gets invoked before any servlet for which it is mapped, can be easily configured for various URL patterns without code changes, and doesn't pollute the hierarchy chain of the servlets the way a base class would.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think of a base servlet as a nuke. It's going to effect everything.

A filter is more presice. You have to map it to each and every resource you want it to effect, but it effects nothing else and can be done so by simply modifying the contents and order of web.xml, not the code.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been using a Filter for a while now. I just needed some "reassurance" that I was doing to most appropriate thing.

Thanks guys.
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
This depending upon the Resources which App server will serv
if your application is getting thousand of hits per min then dont use servlet filert , due to perfornce in servlet filter every request is comming throug servlet filet and responsible to server the satic resources

in other case Filters easy to handle the request. in case of performace

servelter filerts are working on the top of the filters and pp servers


Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic