Page: 3
2. The Structure and Deployment of Web Applications
Q9. You have built a web application with tight security. Several directories ofyour webapp are used for internal purposes and you have overridden the default servlet to send an HTTP403 status code for any request that maps to one of these directories. During testing, the QualityAssurance director decided that they did NOT like seeing the bare response page generated by Firefoxand Internet Explorer. The director recommended that the webapp should return a more user-friendlyweb page that has the same look-and-feel as the webapp plus links to the webapp's search engine. Youhave created this JSP page in the /WEB- INF/jsps/error403.jsp file. You do NOT want to alter the complex logic of the default servlet. How can you declare that the web container must send this JSP page whenever a 403 status is generated?
A. <error-page>
<error-code>403</error-code>
<url>/WEB-INF/jsps/error403.jsp</url>
</error-page>
B. <error-page>
<status-code>403</status-code>
<url>/WEB-INF/jsps/error403.jsp</url>
</error-page>
C. <error-page>
<error-code>403</error-code>
<location>/WEB-INF/jsps/error403.jsp</location>
</error-page>
D. <error-page>
<status-code>403</status-code>
<location>/WEB-INF/jsps/error403.jsp</location>
</error-page>
Answer: C
Q: 10 You want to create a valid directory structure for your Java EE web application, and your application uses tag files and a JAR file. Which three must be located directly in your WEB-INF directory (NOT in a subdirectory of WEB-INF)? (Choose three.)
A. The JAR file
B. A directory called lib
C. A directory called tags
D. A directory called TLDs
E. A directory called classes
F. A directory called META-INF
Answer: B, C, E
Q 11. Given:
11. public class MyServlet extends HttpServlet {
12. public void service(HttpServletRequest request,
13. HttpServletResponse response)
14. throws ServletException, IOException {
15. // insert code here
16. }
17. }
and this element in the web application's deployment descriptor:
<error-page>
<error-code>302</error-code>
<location>/html/error.html</location>
</error-page>
Which, inserted at line 15, causes the container to redirect control to the error.html resource?
A. response.setError(302);
B. response.sendError(302);
C. response.setStatus(302);
D. response.sendRedirect(302);
E. response.sendErrorRedirect(302);
Answer: B
Q12. Which element of the web application deployment descriptor defines the servlet class associated with a servlet instance?
A. <class>
B. <webapp>
C. <servlet>
D. <codebase>
E. <servlet-class>
F. <servlet-mapping>
Answer: E
Q13. Within the web application deployment descriptor, which defines a valid JNDI environment entry?
A. <env-entry>
<env-entry-type>java.lang.Boolean</env-entry-type>
<env-entry-value>true</env-entry-value>
</env-entry>
B. <env-entry>
<env-entry-name>param/MyExampleString</env-entry-name>
<env-entry-value>This is an Example</env-entry-value>
</env-entry>
C. <env-entry>
<env-entry-name>param/MyExampleString</env-entry-name>
<env-entry-type>int</env-entry-type>
<env-entry-value>10</env-entry-value>
</env-entry>
D. <env-entry>
<env-entry-name>param/MyExampleString</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>This is an Example</env-entry-value>
</env-entry>
Answer: D
Q14. Which three are described in the standard web application deployment descriptor? (Choose three.)
A. session configuration
B. MIME type mappings
C. context root for the application
D. servlet instance pool configuration
E. web container default port bindings
F. ServletContext initialization parameters
Answer: A, B, F
Page: 3
1
2
3
4
5
6