• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

HFSJ 2 ed. Final mock exam 65 question

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A programmer is creating a filter for a Java EE web application. Given the following code:

What change(s) are necessary to create a valid filter? (Choose all that apply.)
A. No changes are necessary.
B. A destroy() method must be added.
C. The doFilter() method’s body must be changed.
D. The init() method’s signature must be changed.
E. The doFilter() method’s arguments must be changed.
F. The doFilter() method’s exceptions must be changed.

Book marks B C D and E as correct but as my opinion C is incorrect - filters can block request, make redirects ans dispatches. Call of chain.doFilter() method is not necessary.

Am I correct?
 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kiril.

A programmer is creating a filter for a Java EE web application.


I think, the body must be changed. Here the question is for a Java EE web application. This means, the application deals with http protocol. Thats why, the body must include,
 
Kiril Nugmanov
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chinmaya Chowdary,

But Your described actions are not mandatory. Filter can easily deals with ServletRequest and ServletResponse - everything depends on the logic that will be placed in that filter.

But as example of blocking filter:


just outputs to the console message(that can be just commented in the filter) and it still will be working and correct - if purpose of it - block requests.
 
Chinmaya Chowdary
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kiril. If we don't use the following code in doFilter(), the filter is valid one and will run without any problems.

Here the question is

A programmer is creating a filter for a Java EE web application.


It means the application deals with http protocol. So we need to change the code inside doFilter() method inorder to deal with.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic