Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is Filter Mutli-threaded?  RSS feed

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to Servlet 2.4 Spec6.2.1, only one instance per <filter> in DD is created. But if there are 2 concurrent requests made to 2 servlets sharing the same <filter> definition, would the filter executed in multiple threads (just like servlet)? I cannot find related information in the specification. Could anyone point me to the appropriate location for more information.

Thx
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filter is nothing but a compliment to servlet. It entertains the request just as servlet do. Filter can do some particular things in a nice manner, like
Authentication of requests, Data encryption, Data compression, Logging etc.

Now cheers.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When coding a Filter you must take the same precautions for handling multiple reqests "at the same time" as you presumably take for servlets.

Bill
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello William.


kindly eloborate your answer. If possible explain with an example.
[ September 19, 2005: Message edited by: vishnu prakash ]
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you mean "is a servlet filter thread safe?", not "is a servlet filter multi-threaded?". The servlet filter itself is threadsave as it is simply a method with local variables, but if you reference objects in this method of instance or static scope and they can be changed by another thread of exectuion then those objects must be thread safe.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!