After taking the
test and viewing the answers I am still unsure about them. Can you guys clarify:
Which of the following statements are true?
Choose at least one answer. A. Tag files can contain the tag element that allows attributes to be processed The tag element is unique to tag files and is not used within
jsp pages.
B. tag files cannot process attributes from the calling jsp page
C. the body of a tag file cannot contain scripting
D. the body of a tag file cannot contain EL statements
E. the body of a tag file can be declared as tagdependent
Answers are A, C, E.
I think C is wrong. "tagdependent" allows the body to have unevaluated scripting
Given a deployment descriptor (WEB-XML) with the following tags
<welcome-file-list>
<welcome-file> index.jsp </welcome-file>
<welcome-file> welcome.jsp </welcome-file>
</welcome-file-list>
Which of the following statements are true?
Choose at least one answer.
A. This will cause a runtime error, only one welcome-file can be specified A dd can specify multiple welcome files. They will be returned according to the order they are specified.
B. A request ending with / will return index.jsp if it existss
C. If index.jsp does not exist a requrest ending with / will attempt to return welcome.jsp
D. A request that ends with /welc will return the welcome.jsp page
Answers are B, C
I think none of them are correct. If we map the url
pattern /* to a
servlet. Then this servlet will be served, not the index.jsp or welcome.jsp.
Is the following statement true or false?
A tag that directly extends the TagSupport class provides no direct way of accessing the body of the tag.
Answer: True
I am not sure about the
word "accessing the body". The tag can evaluated the body and output it. I just can not parse the content of the body. I chose false by the way.
Which servlet methods are used by servlets to process the data in form fields?
Choose at least one answer.
A. init
B. servlet
C. doForm
D. doGet
E. doFields
F. doPost
Answer: F. But if the action does not specify a method then doGet() is used. I chose also D.
Is the following statement true or false?
A resource that is included using the RequestDispatcher.include method will share attributes of the originating resource.
Answer: True with the explanation "This is true, for example it would be possible to access an attribute within the session using the getAttribute method for the session object. Note however that
Java objects would not be shared. "
What if the attributes of the originating resource are defined in page scope as the default, can they be used by the included resouce?
Given a valid deployment descriptor (WEB.XML) containing the following code
<context-param>
<param-name>bestwebsite</param-name>
<param-value>www.examulator.com</param-value>
</context-param>
<servlet>
<servlet-name>GetInitParameter</servlet-name>
<servlet-class>com.examulator.GetInitParameter</servlet-class>
<init-param>
<param-name>bestwebsite</param-name>
<param-value>www.javaranch.com</param-value>
</init-param>
</servlet>
And given that cfg is a valid ServletConfig object and ctx is a valid ServletContext object which of the following statements are true?
Choose at least one answer.
A. cfg.getInitParameter("bestwebsite") will return www.examulator.com
B. ctx.getInitParameter("bestwebsite") will return www.javaranch.com
C. ctx.getInitParameter("bestwebsite") will return www.examulator.com
D. cfg.getServletContext().getInitParameter("bestwebsite"); will cause a compile time error
E. ctx.getServletConfig().getInitParameter("bestwebsite"); will cause a compile time error
Answer: C.
I think E is also true. We can't get a config object using ctx.getServletConfig().
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 The whole point of using the wrappers is that you override methods to extend the functionality of the request or response. For example you might override getOutputStream and create a custom version to modify its contents
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 Version 2.4 of the Servlet specification introduced the ability to configure filters to be invoked for request dispatcher forward and include calls. This requires the use of the dispatcher tag within the filter-mapping tag of the deployment descriptor
Answer: A,B,D. But I think B is wrong. Filters with the matching url are called first and then the ones matching servelet name.
Which of the following will compile correctly if placed in a jsp file?
a)
<%@ import page=java.util.*,java.io.* %>
b)
<%@ import=java.util.*,java.io.* %>
c)
<%@ page import=java.util.*,java.io.* %>
d)
<jsp:directive.page import="java.util.*"/>
Answer: C, D. Do we need to have quote around the fully qualified class?
What will happen when you attempt to compile and run the following JSP page contents?
<%request.setAttribute("Two","2");
Integer One = new Integer(1);%>
${One + 1}
${Two}
${Two + 1}
Choose one answer.
A. 1 2 3
B. 2 2 3
C. 1 1
D. 1 null 1
Answer A. I think the answer should be B because ${One + 1} should output 2 since EL would automatically unbox One to be 1.
Thuy Nguyen