• 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

SCWCD Questions on Filters and RequestDispatcher

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

SCWCD Mock Exam



FIlters

1) which of the following is True ?

A.The init method on a filter is called the first time a servlet mapped to that filter is
invoked.

B.Filters associated with a named servlet are applied in the order they appear in the
web application deployment descriptor file.


Correct Answer-B
I think answer should be A as init method is the first method that is called before servicing any request.
and IF there is a url pattern ,named servlet are applied after them irrespective of their order in DD.

----------------------------------------------------------------------------------------------------------------------
RequestDispatcher

2)
Servlet dispatches the
request to the order Work servlet that is mapped in DD to /WEB-INF/Work.do
which of the following is correct ?


A.

B.

Correct answer is B
why cant A be correct answer.
There seems to no syntax error for the code in option A.
 
Greenhorn
Posts: 16
2
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. B is the answer, A is wrong because the init method of Filter is called only once at deployment time when the Filter is loaded by the Container (just like the init method of Servlet), it will never be called again by the container unless you redeploy your app.
2. B is the answer, A is wrong because RequestDispatcher has no method named forwardRequest.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi max,

Option A of the second question , I had posted was wrong.The correct one is the following

A.


B.


Which one is TRUE?
 
max ramos
Greenhorn
Posts: 16
2
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to go with choice A.

Choice B is not safe, if the variable jURL contains an invalid characrer for a URL like space then forwarding the request using this invalid URL would result the forward to fail.

This is only an assumption. If there's a guarantee that jURL will never contain an invalid character then it would be safe to use choice B.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
max,
If the jURL doesnot contain any invalid character,then
why can't A be choosen as the correct answer compared to B ?
Does


performs any special thing to T
Please provide some explanation.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why can't A be choosen as the correct answer compared to B ?
Does format performs any special thing to T parameter.
Please provide some explanation.





 
reply
    Bookmark Topic Watch Topic
  • New Topic