Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Filter trigger sequence

 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Please try the following question and kindly tell the rest why. Thanks.

Which of the statements is true about the following deployment descriptor snippet?
<filter-mapping>
<filter-name>Filter1</filter-name>
<servlet-name>ServletToFilter</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>Filter2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Choose one answer.

a. The filter-mapping tag does not have a servlet-name sub element


b. Filter1 will be invoked before Filter2 if ServletToFilter is requested


c. Filter2 will be invoked before Filter1 if ServletToFilter is requested


d. Only Filter1 will be invoked by a valid request to ServletToFilter

 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a. The filter-mapping tag does not have a servlet-name sub element

Wrong. You can choose a <url-pattern> or a <servlet-name>


b. Filter1 will be invoked before Filter2 if ServletToFilter is requested

Wrong. First the filters with a matching url are placed in the filter chain and are so called first. Then the filters with a matching <servlet-name>


c. Filter2 will be invoked before Filter1 if ServletToFilter is requested

True, see b


d. Only Filter1 will be invoked by a valid request to ServletToFilter

Wrong. It's a valid mapping.

Could you tell me where you found this question. Normally in the Ranch you have to quote your source.
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Regarding the filter sequence, I had a second question which is also from
Marcus Green Mock Exams Three entire SCWCD 70 questions mock exams. Needs free registration

Question:
Which of the following statements are true?
Choose at least one answer.

a. HttpServletResponseWrapper takes a constructor parameter of type HttpServletResponse


b. Filters are called in the order they appear in the deployment descriptor


c. Methods of the wrapper classes must not be overridden


d. Filters are an example of the Intercepting Filter design patttern


e. Filters can only be invoked on incoming requests, and not on a dispatcher forward or include


I selected a and d, but the answer told me b is also the right one. Please help to confirm this. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic