QUESTION NO: 181
Your web application uses a simple architecture in which servlets handle requests and then
forward to a JSP using a request dispatcher. You need to pass information calculated in the
servlet to the JSP for view generation. This information must NOT be accessible to any other
servlet, JSP or session in the webapp. Which two techniques can you use to accomplish this goal?
(Choose two.)
A. Add attributes to the session object.
B. Add attributes on the request object.
C. Add parameters to the request object.
D. Use the pageContext object to add request attributes.
E. Add parameters to the JSP's URL when generating the request dispatcher.
Answer: B,E
QUESTION NO: 182
For which three events can web application event listeners be registered? (Choose three.)
A. when a session is created
B. after a servlet is destroyed
C. when a session has timed out
D. when a cookie has been created
E. when a servlet has forwarded a request
F. when a session attribute value is changed
Answer: A,C,F
QUESTION NO: 183
Given:
String value = getServletContext().getInitParameter("foo");
in an HttpServlet and a web application deployment descriptor that contains:
<context-param>
<param-name>foo</param-name>
<param-value>frodo</param-value>
</context-param>
Which two are true? (Choose two.)
A. The foo initialization parameter CANNOT be set programmatically.
B. Compilation fails because getInitParameter returns type Object.
C. The foo initialization parameter is NOT a servlet initialization parameter.
D. Compilation fails because ServletContext does NOT have a getInitParameter method.
E. The foo parameter must be defined within the <servlet> element of the deployment descriptor.
F. The foo initialization parameter can also be retrieved using
getServletConfig().getInitParameter("foo").
Answer: A,C
QUESTION NO: 184
Click the Exhibit button. Given the web application deployment descriptor elements:
11. <filter>
12. <filter-name>ParamAdder</filter-name>
13. <filter-class>com.example.ParamAdder</filter-class>
14. </filter>
...
31. <filter-mapping>
32. <filter-name>ParamAdder</filter-name>
33. <servlet-name>Destination</servlet-name>
34. </filter-mapping>
...
55. <servlet-mapping>
56. <servlet-name>Destination</servlet-name>
57. <url-pattern>/dest/Destination</url-pattern>
58. </servlet-mapping>
What is the result of a client request of the Source servlet with no query string?
A. The output "filterAdded = null" is written to the response stream.
B. The output "filterAdded = addedByFilter" is written to the response stream.
C. An exception is thrown at runtime within the service method of the Source servlet.
D. An exception is thrown at runtime within the service method of the Destination servlet.
Answer: A
QUESTION NO: 185
Given a Filter class definition with this method:
21. public void doFilter(ServletRequest request,
22. ServletResponse response,
23. FilterChain chain)
24. throws ServletException, IOException {
25. // insert code here
26. }
Which should you insert at line 25 to properly invoke the next filter in the chain, or the target
servlet if there are no more filters?
A. chain.forward(request, response);
B. chain.doFilter(request, response);
C. request.forward(request, response);
D. request.doFilter(request, response);
Answer: B
QUESTION NO: 186
Servlet A forwarded a request to servlet B using the forward method of RequestDispatcher. What
attribute in B's request object contains the URI of the original request received by servlet A?
A. REQUEST_URI
B. javax.servlet.forward.request_uri
C. javax.servlet.forward.REQUEST_URI
D. javax.servlet.request_dispatcher.request_uri
E. javax.servlet.request_dispatcher.REQUEST_URI
Answer: B
QUESTION NO: 187
You want to create a valid directory structure for your Java EE web application, and you want to
put your web application into a WAR file called MyApp.war. Which two are true about the WAR
file? (Choose two.)
A. At deploy time, Java EE containers add a directory called META-INF directly into the MyApp
directory.
B. At deploy time, Java EE containers add a file called MANIFEST.MF directly into the MyApp
directory.
C. It can instruct your Java EE container to verify, at deploy time, whether you have properly
configured your application's classes.
D. At deploy time, Java EE containers add a directory call META-WAR directly into the MyApp
directory.
Answer: A,C
QUESTION NO: 188
Which two from the web application deployment descriptor are valid? (Choose two.)
A. <error-page>
<exception-type>*</exception-type>
<location>/error.html</location>
</error-page>
B. <error-page>
<exception-type>java.lang.Error</exception-type>
<location>/error.html</location>
</error-page>
C. <error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.html</location>
</error-page>
D. <error-page>
<exception-type>java.io.IOException</exception-type>
<location>/error.html</location>
</error-page>
E. <error-page>
<exception-type>NullPointerException</exception-type>
<location>/error.html</location>
</error-page>
Answer: C,D
QUESTION NO: 189
After a merger with another small business, your company has inherited a legacy WAR file but the
original source files were lost. After reading the documentation of that web application, you
discover that the WAR file contains a useful tag library that you want to reuse in your own webapp
packaged as a WAR file.
What do you need to do to reuse this tag library?
A. Simply rename the legacy WAR file as a JAR file and place it in your webapp's library directory.
B. Unpack the legacy WAR file, move the TLD file to the META-INF directory, repackage the
whole thing as a JAR file, and place that JAR file in your webapp's library directory.
C. Unpack the legacy WAR file, move the TLD file to the META-INF directory, move the class files
to the top-level directory, repackage the whole thing as a JAR file, and place that JAR file in your
webapp's library directory.
D. Unpack the legacy WAR file, move the TLD file to the META-INF directory, move the class files
to the top-level directory, repackage the WAR, and place that WAR file in your webapp's WEB-INF
directory.
Answer: C
QUESTION NO: 190
Which path is required to be present within a WAR file?
A. /classes
B. /index.html
C. /MANIFEST-INF
D. /WEB-INF/web.xml
E. /WEB-INF/classes
F. /WEB-INF/index.html
G. /META-INF/index.xml
Answer: D
No comments:
Post a Comment