javabeat
I have some queries in the following question
Please Help.
1.Consider the following description of a tag in a TLD:
Which of the following statements regarding the above tag are correct?
Select 2 correct options.
A.It is an empty tag.
B.It may be used as an empty tag.//answer
C.It must have a body
D.It must implement BodyTag interface.//answer
E.It may take an attribute named 'name'. But if present, its value must be dynamic.
Why is D one of the correct answer ?
If only one option has to be chosen I think B is the correct answer as Tagdepedent body can be empty
-------------------------------------------------------------------------------------------------------------
2.A Tag Handler implements BodyTag interface. How many times its doAfterBody method may be called?
Select 1 correct option.
A.BodyTag does not support doAfterBody.
B.0
C.1
D.0 or 1
E.Any number of times.----correct answer
If i leave the body of tag as empty then the doAfterBody wouldnot be called
so ,anser can be B also.
-------------------------------------------------------------------------------------------
3.Which of the following are true regarding the parameters defined using the <context-param> element of a deployment descriptor?
correct answer:.
A.They are
thread safe.
B.They are accessible from multiple threads simultaneously and from any
servlet of the web application.
Arent the 2 options contradictory ?
If parameters are thread safe that means they cant be used when one thread uses them
how is it possible?
------------------------------------------------------------------------------------------
4.Which of the following is a sensible way of sending an error page to the client in case of a business exception that extends from java.lang.Exception?
Select 2 correct options.
A.
Catch the exception and use RequestDispatcher to forward the request to the error page.---correct ans.
B.Don't catch the exception and define the 'exception to error-page' mapping in web.xml
C.
Catch the exception, wrap it into ServletException and define the 'business exception to error-page' mapping in web.xml--correct ans
How is A and C correct ?
I think the easiest way is to define a exception to error page mapping with exception-type of throwable class
----------------------------------------------------------------------------------------------------------
5.Which of the following XML frgaments correctly define the <login-config> element of web.xml?
Select 3 correct options.
A.1-----correct answer
B.2-----correct answer
C.3-----correct answer
D.4
E.5
How is 2 option correct ?
form-login-config is for FORM (auth-method) only.
-------------------------------------------------------------------------------------------------------------
6.Following is the code for doGet() method of TestServlet. Which of the given statements about it are correct?
Select 2 correct options.
A.This will not compile.
B.This will compile but will not work as expected.
C.This code will work just fine.
D.It will compile but not work properly if //1 is replaced with: RequestDispatcher rd = req.getRequestDispatcher("Login.jsp");
E.It will compile and will work properly if //1 is replaced with: RequestDispatcher rd = req.getRequestDispatcher("Login.jsp");
correct answer: C and E
According to Servlet 2.4 specification
SRV.8.1 Obtaining a RequestDispatcher
The getRequestDispatcher method takes a String argument describing a
path within the scope of the ServletContext. This path must be relative to the root
of the ServletContext and begin with a ‘/’.
Answer should be A and E