• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in servlet spec 2.4

 
arun shanmugam kumar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I am preparing for SCWCD exam...
In page 52 of the servlet spec 2.4 it is given as follows ,

"step 5: After invocation of the next filter in the chain, the filter may
examine response headers."

My question is does it applies equally well to request headers also ?

If yes , then what is the use in examining request/response headers after invoking the next filter in the chain ?

Thanks in advance!

Arun { SCJP1.4 , SCWCD(in the race ..) }
 
Arvind Giri
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question is does it applies equally well to request headers also ?


Yes!
In Step 1 it mentions that:
Step 1: The method examines the request�s headers.

If yes , then what is the use in examining request/response headers after invoking the next filter in the chain ?


Well, suppose you have a filter to compress text/html output, but you don't want to compress image/gif(or any other) output, then examining response header will be of great help.

Please correct me if I am wrong?
 
arun shanmugam kumar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Yes!
In Step 1 it mentions that:
Step 1: The method examines the request�s headers.


sorry! what i meant to ask is with reference to step 5 can the filter examine request headers after it invokes the next filter in the chain.

And if yes then what is the use of examining request/response headers after it passes the baton to the next filter ? ( got the question ?? )

Regards,
Arun { SCJP1.4 , SCWCD(in the race ..) }
 
Arvind Giri
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry! what i meant to ask is with reference to step 5 can the filter examine request headers after it invokes the next filter in the chain.


Of course we can, But it would be of no use. At step 5, we can have some logic which depends on the response header(as mentioned in my previous post), but I didn't find any use of examining request header at step 5.
 
arun shanmugam kumar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i think you still haven't got my question
i will make it clear ..

This is what given in the spec:

"step 5: After invocation of the next filter in the chain, the filter may examine response headers."

Q1.
The scenario is : (for example) Filter2 after doing some processing with the response object give it to Filter1.
With respect to step 5 ,it means to tell that now filter2 may examine response headers even after giving it to filter1.

Now my question is : what is the need for it? or Is there a flaw in my understanding of the meaning of step 5?



Q2. Does the rule of step 5 also apply to request object?(because it is not explicitly mentioned about request object)

(OR) Simply put , Is the below statement valid ?

"After invocation of the next filter in the chain, the filter may examine request headers"

hope you all get it

Regards,

Arun { SCJP1.4 , SCWCD(in the race ..) }
 
Arvind Giri
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wait.....

After invocation of the next filter in the chain.
means after filterChain.doFilter() statement in filter.


Q1.
The scenario is : (for example) Filter2 after doing some processing with the response object give it to Filter1.
With respect to step 5 ,it means to tell that now filter2 may examine response headers even after giving it to filter1.


With respect to step 5 it means that when control will return to filter2 from call stack of filters and servlets(and servlet has generated response),
then filter 2 may/should examine response header. i.e. after filterChain.doFilter() statement.



Q2. Does the rule of step 5 also apply to request object?(because it is not explicitly mentioned about request object)

(OR) Simply put , Is the below statement valid ?

"After invocation of the next filter in the chain, the filter may examine request headers"


Hope now you are able to figure it out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic