This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

filter objects

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys

is filter objects are created for every new request

or created once for every new session

is their any way to control or it should create for every new request

or for every new session

looking for your replies
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe this article will help you with your questions

Filters
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filters are just a compliment to Servlet. You can take it as a special kind of servlet that can transform a request or modify a response.

An Excerpt from the link given above:
They don't actually create a response. They are preprocessors of the request before it reaches a servlet, and/or postprocessors of the response leaving a servlet.
 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
Remko Strating and Adeel Ansari for your response

i didnt found answere to my question in your response
what iam asking is How the instances of the Filter are maintained
in the web server


in struts action-servlet instance is only once created

similar to action servlet filter objects are created once or created new for
every new request or created for every new session
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adeel's answer covered it.
A Filter's life cycle is like a servlet's
For more information read section SRV.6.2.1 in the servlet specification:


SRV.6.2.1 Filter Lifecycle
After deployment of the Web application, and before a request causes the container
to access a Web resource, the container must locate the list of filters that must be
applied to the Web resource as described below. The container must ensure that it
has instantiated a filter of the appropriate class for each filter in the list, and called its
init(FilterConfig config) method. The filter may throw an exception to indicate
that it cannot function properly. If the exception is of type UnavailableException,
the container may examine the isPermanent attribute of the exception and may
choose to retry the filter at some later time.
Only one instance per <filter> declaration in the deployment descriptor is
instantiated per Java Virtual Machine (JVMTM) of the container. The container

provides the filter config as declared in the filter´┐Żs deployment descriptor, the
reference to the ServletContext for the Web application, and the set of
initialization parameters.




 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for correcting me ben
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic