aspose file tools*
The moose likes Servlets and the fly likes Filter vs Base Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Filter vs Base Servlet" Watch "Filter vs Base Servlet" New topic
Author

Filter vs Base Servlet

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

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?


GenRocket - A Test Data Generation Platform
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

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.
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Filter vs Base Servlet
 
Similar Threads
Filter configuration?
Struts Filter
A forward in a include page?
j_security_check and user info
Interview question: What's the difference between and Servlet and Filter?