This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

EPractice Lab quiz 2 about filter

 
Ranch Hand
Posts: 1829
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You want to create a filter for your web application and your filter will implement javax.servlet.Filter.
Which two statements are true?
[ Choose two ]

a. Your filter class must implement an init method and a destroy method.
b. Your filter class must also implement javax.servlet.FilterChain.
c. When your filter chains to the next filter, it should pass the same arguments it received in its doFilter method.
d. The method that your filter invokes on the object it received that implements javax.servlet.FilterChain can invoke either another filter or a servlet.
e. Your filter class must implement a doFilter method that takes, among other things, an HTTPServletRequest object and an HTTPServletResponse object.


Choice A and Choice D are correct

A filter is an object that performs filtering tasks on either the request to a resource (a servlet or static content), or on the response from a resource, or both.
Filters perform filtering in the doFilter method. Every Filter has access to a FilterConfig object from which it can obtain its initialization parameters, and a reference to the ServletContext which it can use, for example, to load resources needed for filtering tasks.
Filters are configured in the deployment descriptor of a web application.
Examples that have been identified for this design are:
1. Authentication Filters
2. Logging and Auditing Filters
3. Image conversion Filters
4. Data compression Filters
5. Encryption Filters
6. Tokenizing Filters
7. Filters that trigger resource access events
8. XSL/T filters
9. Mime-type chain Filter
A FilterChain is an object provided by the servlet container to the developer giving a view into the invocation chain of a filtered request for a resource. Filters use the FilterChain to invoke the next filter in the chain, or if the calling filter is the last filter in the chain, to invoke the resource at the end of the chain.
Your filter class must implement an init method and a destroy method.
The method that your filter invokes on the object it received that implements javax.servlet.FilterChain can invoke either another filter or a servlet.



I think C is also correct.
For example:


Reference:
http://tutorials.jenkov.com/java-servlets/servlet-filters.html
 
Marshal
Posts: 25215
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you follow the link from that tutorial to this one:

http://tutorials.jenkov.com/java-servlets/gzip-servlet-filter.html

you'll find an example of a filter whose doFilter method does NOT pass the same arguments it received when chaining to the next filter.
 
It's exactly the same and completely different as this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!