• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

filter mock test queation

 
rachna jain
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All


I am aware that doFilter() need not to call chain.dofilter()

but q -65 page 824 HFS says option c is right(if nothing else then dofilter() must be invoked in body

Please explain
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well,

the chaoin.doFilter(request, response) forwards to the next filter, or - if there is no more filter in the chain - to the executing servlet...

if you do not make this call, you wont get an exception thrown, but the request will die a horrible death and serve a blank page to the requester because it never reaches the end of the chain ..
 
rachna jain
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again for the explanation but if the question will ask it must be there ?

Then what should we answer?

somewhere they say not necessary but in above mensioned question ther are saying it must be there

i think if it will not throw error then its presence is not mandatory.

Correct me if i am wrong....what should we answer
 
rachna jain
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing well that is also possible that there is no next filter in chain then it is not needed and we will get the response also.
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nope ...

if there is no next filter, the filterChain.doFilte(req, resp) will forward to the servlet, jsp or whatever the requesting url is mapped to ...

so this call is absolutely needed.

as for the question ... it is sometimes a matter of how you look at it ...
even though not calling doFilter will not result in an exception, it will blow the execution ... so the answer can be seen as correct
 
rachna jain
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its clear thanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic