Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

From HFJS, coffee cram, some options

 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1- Filter chain order is affected by whether filter mappings are declared
via <url-pattern> or via <servlet-name>. TRUE

I need clarification on this. Any input?

2- Filter supports an initialization mechanism that includes an init()
method that is guaranteed to be called before the filter is used to handle
requests.
FALSE

Is this incorrect due to bold line?


Thanks,
 
K Sanjeet
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Its true. As the filters mapped with url-pattern are lined up first and then filters mapped with servlet-name.

2. It looks confusing. But should be true.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranjeet,


A agree with what you say regarding Statement #1. My doubt is whether these
two things match (what you say and what is given there). Does that mean
something else.


I am still doubtful regarding statement #2. It is given false in the book.
If it is really false, I guess the reason is Filter does not handle the
client request. Not sure.

Thanks,
 
anil kumar
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

In the filter life cycle there is no init() method.There is a method called init(FilterConfig).

So the statement is false.

Thanks

Anil Kumar
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it Question 5 page 703 ?
http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christopher,

It was an errata.


Anil:

Kindly refer to page 78 of the Specification:


->Instantiate an instance of each event listener identified by a <listener>
element in the deployment descriptor.

->For instantiated listener instances that implement ServletContextListener,
call the contextInitialized() method.

->Instantiate an instance of each filter identified by a <filter> element
in the deployment descriptor and call each filter instance�s init()
method.


->Instantiate an instance of each servlet identified by a <servlet> element
that includes a <load-on-startup> element in the order defined by the
load-onstartup element values, and call each servlet instance�s init()
method.


Thanks,
 
anil kumar
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have seen that,and i knew, but i am speaking about that particular question.

I am saying that ,that may be the reason...

Any way thanks

Thanks Christophe Verre for providing updated eratta


Thanks

Anil Kumar
[ August 07, 2007: Message edited by: anil kumar ]
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is init() method apart from init(FilterConfig).

Is that correct (init() exits), as specification says or the question is
talking about init(FilterConfig) as Anil pointed out?


Thanks,
 
anil kumar
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

If you consider the statements from specification the question is correct.But according to the subject or from head first book.we can sure that the answer is false.I thought that question as specific.I did not think that question as a general one.

If the same question appeared in exam i would go for false .Because there is no init() method in filer life cycle.

Let us wait and see what others comments on this.



Thanks

Anil Kumar
 
K Sanjeet
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anil,

I dont have the details of the question but looking at only the stmt and assuming that its referring to the init() method with the right argument the stmt looks true.

What do you say?

Thanks
 
anil kumar
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Sanjeet

if this is the statement
--------------------------------------------------------------------------
Filter supports an initialization mechanism that includes an
init(FilterConfig config) method that is guaranteed to be called before the filter is used to handle requests
-------------------------------------------------------------------------

Then the answer is true



Because according to the specification 2.4 .The container has to create an instance of the filter class and must call the init(FilterConfig config) at deployment time or just before processing the first request to the particular servlet or jsp.


Thanks

Anil Kumar
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anil,


HFJS errata says that option to be correct. In specification init() method is said to be called although there is no direct mention of init(), instead
init(FilterConfig) exits.

I wonder if this sort of confusing questions we encounter in the real exam,
it would be very difficult.


Thanks,
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question has been debated quite often at the ranch. I sometimes say that there is no init() method. But the question seems to be asked in an awkward manner, and the errata of HFSJ has been updated accordingly.
Be sure that you won't get such an ambiguous question at the exam.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic