• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic