Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filters - could not understand

 
Prem Vinodh
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

This is my first post on Servlets and Jsp.
Planning to take my certification at the end of next month.

I was reading the Servlet 3.0 Specification on Filters.

The following extract has been taken from the Servlet 3.0 Speficiation
Among the types of functionality available to the developer needing to use filters are
the following:
■ The accessing of a resource before a request to it is invoked.


Could someone please explain what the above means
to access a resource before a request to it is invoked
?

I was of the assumption that we would modify the request, response or header data using filters.
The request before it reaches the resource or response after the call comes back from the resource
or the header information either before the request reaches the resource or when response is on its way back from the resource.

So I am a bit confused as to what the above sentence means.

Thanks in advance.
 
Prem Vinodh
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

Is it that the container first checks whether the resource is present and if the resource is not present then it will not invoke the filter on the particular resource.
So for this the container first needs to check whether the resource is present.

So is this what is meant by the following statement
The accessing of a resource before a request to it is invoked.

Thanks in advance

 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think that suppose you have a resource(static or dynamic). to make it clear lets say the resource is a jar file or something. now with filter before you request this resource(jar file) you can access it using FilterConfig.getServletContext.getResource(String). the specs talk about resource so resource means any servlet, jsp, html .
 
Prem Vinodh
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sirji,

Thanks for the reply.
Ok now I see the actual meaning of it.

Thanks
Prem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic