Q: 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
Q: 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
Q: 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
Q: 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?
Q: 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
Q: 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
Q: 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
Q: 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>
an XML web service for B2B HTML for web-based clients WML for wireless customers
Which design pattern provides a solution for this problem?
A. Session Facade
B. Business Delegate
C. Data Access Object
D. Model-View-Controller
E. Chain of Responsibility
Answer: D
Q: 209 Which two are characteristics of the Front Controller pattern? (Choose two.)
A. It simplifies remote interfaces to distributed objects.
B. It promotes cleaner application partitioning and encourages reuse.
C. It provides an initial point of contact for handling all related requests.
D. It reduces maintainability due to the increased complexity of the design.
E. It provides loosely coupled handlers that can be combined in various permutations.
Answer: B, C
Q: 210 Squeaky Beans Inc. hired an outside consultant to develop their web application. To finish the job quickly, the consultant created several dozen JSP pages that directly communicate with the database. The Squeaky business team has since purchased a set of business objects to model their system, and the Squeaky developer charged with maintaining the web application must now refactor all the JSPs to work with the new system. Which pattern can the developer use to solve this problem?
A. Transfer Object
B. Service Locator
C. Intercepting Filter
D. Business Delegate
Answer: D
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
Q: 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
Q: 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
Q: 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
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
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
Q: 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
Q: 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.
Q: 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>
<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>
<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
Q: 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.
Answer: C
Q: 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
Q: 191 Given:
11. <servlet>
12. <servlet-name>catalog</servlet-name>
13. <jsp-file>/catalogTemplate.jsp</jsp-file>
14. <load-on-startup>10</load-on-startup>
15. </servlet>
Which two are true? (Choose two.)
A. Line 13 is not valid for a servlet declaration.
B. Line 14 is not valid for a servlet declaration.
C. One instance of the servlet will be loaded at startup.
D. Ten instances of the servlet will be loaded at startup.
E. The servlet will be referenced by the name catalog in mappings.
Answer: C, E
Q: 192 You have built a web application with tight security. Several directories of your webapp are used for internal purposes and you have overridden the default servlet to send an HTTP 403 status code for any request that maps to one of these directories. During testing, the Quality Assurance director decided that they did NOT like seeing the bare response page generated by Firefox and Internet Explorer. The director recommended that the webapp should return a more user-friendly web page that has the same look-and-feel as the webapp plus links to the webapp's search engine. You have 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: 193 Given a portion of a valid Java EE web application's directory structure:
MyApp
|
|-- Directory1
| |-- File1.html
|
|-- META-INF
| |-- File2.html
|
|-- WEB-INF
|-- File3.html
You want to know whether File1.html, File2.html, and/or File3.html is protected from direct access by your web client's browsers.What statement is true?
A. All three files are directly accessible.
B. Only File1.html is directly accessible.
C. Only File2.html is directly accessible.
D. Only File3.html is directly accessible.
E. Only File1.html and File2.html are directly accessible.
F. Only File1.html and File3.html are directly accessible.
G. Only File2.html and File3.html are directly accessible.
Answer: B
Q: 194 A web component accesses a local EJB session bean with a component interface of com.example.Account with a home interface of com.example.AccountHome and a JNDI reference of ejb/Account. Which makes the local EJB component accessible to the web components in the web application deployment descriptor?
A. <env-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local>
</env-ref>
B. <resource-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local>
</resource-ref>
C. <ejb-local-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local>
</ejb-local-ref>
D. <ejb-remote-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local> </ejb-remote-ref>
Answer: C
Q: 195 One of the use cases in your web application uses many session-scoped attributes. At the end of the use case, you want to clear out this set of attributes from the session object. Assume that this static variable holds this set of attribute names:
201. private static final Set<String> USE_CASE_ATTRS;
202. static {
203. USE_CASE_ATTRS.add("customerOID");
204. USE_CASE_ATTRS.add("custMgrBean");
205. USE_CASE_ATTRS.add("orderOID");
206. USE_CASE_ATTRS.add("orderMgrBean");
207. }
Which code snippet deletes these attributes from the session object?
A. session.removeAll(USE_CASE_ATTRS);
B. for ( String attr : USE_CASE_ATTRS ) { session.remove(attr);
}
C. for ( String attr : USE_CASE_ATTRS ) { session.removeAttribute(attr);
}
D. for ( String attr : USE_CASE_ATTRS ) { session.deleteAttribute(attr);
}
E. session.deleteAllAttributes(USE_CASE_ATTRS);
Answer: C
Q: 196 Given an HttpServletRequest request:
22. String id = request.getParameter("jsessionid");
23. // insert code here
24. String name = (String) session.getAttribute("name");
Which three can be placed at line 23 to retrieve an existing HttpSession object? (Choose three.)
A. HttpSession session = request.getSession();
B. HttpSession session = request.getSession(id);
C. HttpSession session = request.getSession(true);
D. HttpSession session = request.getSession(false);
A. Only a single instance of MyObject may exist within a session.
B. The unbound method of the MyObject instance is called when the session to which it is bound times out.
C. The com.example.MyObject must be declared as a servlet event listener in the web application deployment descriptor.
D. The valueUnbound method of the MyObject instance is called when the session to which it is bound times out.
Answer: D
Q: 200 As a convenience feature, your web pages include an Ajax request every five minutes to a special servlet that monitors the age of the user's session. The client-side JavaScript that handles the Ajax callback displays a message on the screen as the session ages. The Ajax call does NOT pass any cookies, but it passes the session ID in a request parameter called sessionID. In addition, assume that your webapp keeps a hashmap of session objects by the ID. Here is a partial implementation of this servlet:
10. public class SessionAgeServlet extends HttpServlet {
11. public void service(HttpServletRequest request, HttpServletResponse) throws IOException {
12. String sessionID = request.getParameter("sessionID");
13. HttpSession session = getSession(sessionID);
14. long age = // your code here
15. response.getWriter().print(age);
16. }
... // more code here 47. }
Which code snippet on line 14, will determine the age of the session?
A. session.getMaxInactiveInterval();
B. session.getLastAccessed().getTime() - session.getCreationTime().getTime();
C. session.getLastAccessedTime().getTime() - session.getCreationTime().getTime();
D. session.getLastAccessed() - session.getCreationTime();
E. session.getMaxInactiveInterval() - session.getCreationTime();
F. session.getLastAccessedTime() - session.getCreationTime();
Answer: F
Q: 201 Which statement is true about web container session management?
A. Access to session-scoped attributes is guaranteed to be thread-safe by the web container.
B. To activate URL rewriting, the developer must use the HttpServletResponse.setURLRewriting method.
C. If the web application uses HTTPS, then the web container may use the data on the HTTPS request stream to identify the client.
D. The JSESSIONID cookie is stored permanently on the client so that a user may return to the web application and the web container will rejoin that session.
Answer: C
Q: 202 You are designing an n-tier Java EE application. You have already decided that some of your JSPs will need to get data from a Customer entity bean. You are trying to decide whether to use a Customer stub object or a Transfer Object. Which two statements are true? (Choose two.)
A. The stub will increase network traffic.
B. The Transfer Object will decrease data staleness.
C. The stub will increase the logic necessary in the JSPs.
D. In both cases, the JSPs can use EL expressions to get data.
E. Only the Transfer Object will need to use a Business Delegate.
F. Using the stub approach allows you to design the application without using a Service Locator.
Answer: A, D
Q: 203 Which two are characteristics of the Intercepting Filter pattern? (Choose two.)
A. It provides centralized request handling for incoming requests.
B. It forces resource authentication to be distributed across web components.
C. It reduces coupling between presentation-tier clients and underlying business services.
D. It can be added and removed unobtrusively, without requiring changes to existing code.
E. It allows preprocessing and postprocessing on the incoming requests and outgoing responses.
Answer: D, E
Q: 204 A developer has created a web application that includes a servlet for each use case in the application. These servlets have become rather difficult to maintain because the request processing methods have become very large. There is also common processing code in many servlets because these use cases are very similar. Which two design patterns can be used together to refactor and simplify this web application? (Choose two.)
A. Proxy
B. View Helper
C. F ront Controller
D. Session Facade
E. Business Delegate
F. Model-View-Controller
Answer: C, F
Q: 205 A developer is designing a multi-tier web application and discovers a need to hide the details of establishing and maintaining remote communications from the client. In addition, the application needs to find, in a transparent manner, the heterogeneous business components used to service the client's requests. Which design patterns, working together, address these issues?
A. Business Delegate and Transfer Object
B. Business Delegate and Service Locator
C. Front Controller and Business Delegate
D. Intercepting Filter and Transfer Object
E. Model-View-Controller and Intercepting Filter
Answer: B
Q: 206 A developer is designing a web application that must support multiple interfaces, including:
an XML web service for B2B HTML for web-based clients WML for wireless customers
Which design pattern provides a solution for this problem?
A. Session Facade
B. Business Delegate
C. Data Access Object
D. Model-View-Controller
E. Chain of Responsibility
Answer: D
Q: 207 A developer is designing a web application which extensively uses EJBs and JMS. The developer finds that there is a lot of duplicated code to build the JNDI contexts to access the beans and queues. Further, because of the complexity, there are numerous errors in the code. Which J2EE design pattern provides a solution for this problem?
A. Command
B. Transfer Object
C. Service Locator
D. Session Facade
E. Business Delegate
F. Data Access Object
Answer: C
Q: 208 A developer is designing a web application that must support multiple interfaces, including:
<exception-type>NullPointerException</exception-type> <location>/error.html</location>
</error-page>
Answer: C, D
Q: 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
Q: 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
Q: 191 Given:
11. <servlet>
12. <servlet-name>catalog</servlet-name>
13. <jsp-file>/catalogTemplate.jsp</jsp-file>
14. <load-on-startup>10</load-on-startup>
15. </servlet>
Which two are true? (Choose two.)
A. Line 13 is not valid for a servlet declaration.
B. Line 14 is not valid for a servlet declaration.
C. One instance of the servlet will be loaded at startup.
D. Ten instances of the servlet will be loaded at startup.
E. The servlet will be referenced by the name catalog in mappings.
Answer: C, E
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: 193 Given a portion of a valid Java EE web application's directory structure:
MyApp
|
|-- Directory1
| |-- File1.html
|
|-- META-INF
| |-- File2.html
|
|-- WEB-INF
|-- File3.html
You want to know whether File1.html, File2.html, and/or File3.html is protected from direct access by your web client's browsers.What statement is true?
B. Only File1.html is directly accessible.
C. Only File2.html is directly accessible.
D. Only File3.html is directly accessible.
E. Only File1.html and File2.html are directly accessible.
F. Only File1.html and File3.html are directly accessible.
G. Only File2.html and File3.html are directly accessible.
Answer: B
Q: 194 A web component accesses a local EJB session bean with a component interface of com.example.Account with a home interface of com.example.AccountHome and a JNDI reference of ejb/Account. Which makes the local EJB component accessible to the web components in the web application deployment descriptor?
A. <env-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local>
</env-ref>
B. <resource-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local>
</resource-ref>
C. <ejb-local-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local>
</ejb-local-ref>
D. <ejb-remote-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local> </ejb-remote-ref>
Q: 195 One of the use cases in your web application uses many session-scoped attributes. At the end of the use case, you want to clear out this set of attributes from the session object. Assume that this static variable holds this set of attribute names:
201. private static final Set<String> USE_CASE_ATTRS;
202. static {
203. USE_CASE_ATTRS.add("customerOID");
204. USE_CASE_ATTRS.add("custMgrBean");
205. USE_CASE_ATTRS.add("orderOID");
206. USE_CASE_ATTRS.add("orderMgrBean");
207. }
Which code snippet deletes these attributes from the session object?
A. session.removeAll(USE_CASE_ATTRS);
B. for ( String attr : USE_CASE_ATTRS ) { session.remove(attr);
}
C. for ( String attr : USE_CASE_ATTRS ) { session.removeAttribute(attr);
}
D. for ( String attr : USE_CASE_ATTRS ) { session.deleteAttribute(attr);
}
E. session.deleteAllAttributes(USE_CASE_ATTRS);
Answer: C
Q: 196 Given an HttpServletRequest request:
22. String id = request.getParameter("jsessionid");
23. // insert code here
24. String name = (String) session.getAttribute("name");
Which three can be placed at line 23 to retrieve an existing HttpSession object? (Choose three.)
A. HttpSession session = request.getSession();
B. HttpSession session = request.getSession(id);
C. HttpSession session = request.getSession(true);
D. HttpSession session = request.getSession(false);
E. HttpSession session = request.getSession("jsessionid");
Answer: A, C, D
Q: 197 A developer for the company web site has been told that users may turn off cookie support in their browsers. What must the developer do to ensure that these customers can still use the web application?
A. The developer must ensure that every URL is properly encoded using the appropriate URL rewriting APIs.
B. The developer must provide an alternate mechanism for managing sessions and abandon the HttpSession mechanism entirely.
C. The developer can ignore this issue. Web containers are required to support automatic URL rewriting when cookies are not supported.
D. The developer must add the string ?id=<sessionid> to the end of every URL to ensure that the conversation with the browser can continue.
Answer: A
Q: 198 You need to store a floating point number, called Tsquare, in the session scope. Which two code snippets allow you to retrieve this value? (Choose two.)
A. float Tsquare = session.getFloatAttribute("Tsquare");
B. float Tsquare = (Float) session.getAttribute("Tsquare");
C. float Tsquare = (float) session.getNumericAttribute("Tsquare");
D. float Tsquare = ((Float) session.getAttribute.("Tsquare")).floatValue();
E. float Tsquare = ((Float) session.getFloatAttribute.("Tsquare")).floatValue;
F. float Tsquare = ((Float) session.getNumericAttribute.("Tsquare")).floatValue;
Answer: B, D
Q: 199 Given the definition of MyObject and that an instance of MyObject is bound as a session attribute:
8. package com.example;
9. public class MyObject implements
10. javax.servlet.http.HttpSessionBindingListener {
11. // class body code here
12. }
Which is true?
Answer: A, C, D
Q: 197 A developer for the company web site has been told that users may turn off cookie support in their browsers. What must the developer do to ensure that these customers can still use the web application?
A. The developer must ensure that every URL is properly encoded using the appropriate URL rewriting APIs.
B. The developer must provide an alternate mechanism for managing sessions and abandon the HttpSession mechanism entirely.
C. The developer can ignore this issue. Web containers are required to support automatic URL rewriting when cookies are not supported.
D. The developer must add the string ?id=<sessionid> to the end of every URL to ensure that the conversation with the browser can continue.
Answer: A
Q: 198 You need to store a floating point number, called Tsquare, in the session scope. Which two code snippets allow you to retrieve this value? (Choose two.)
A. float Tsquare = session.getFloatAttribute("Tsquare");
B. float Tsquare = (Float) session.getAttribute("Tsquare");
C. float Tsquare = (float) session.getNumericAttribute("Tsquare");
D. float Tsquare = ((Float) session.getAttribute.("Tsquare")).floatValue();
E. float Tsquare = ((Float) session.getFloatAttribute.("Tsquare")).floatValue;
F. float Tsquare = ((Float) session.getNumericAttribute.("Tsquare")).floatValue;
Answer: B, D
Q: 199 Given the definition of MyObject and that an instance of MyObject is bound as a session attribute:
8. package com.example;
9. public class MyObject implements
10. javax.servlet.http.HttpSessionBindingListener {
11. // class body code here
12. }
Which is true?
B. The unbound method of the MyObject instance is called when the session to which it is bound times out.
C. The com.example.MyObject must be declared as a servlet event listener in the web application deployment descriptor.
D. The valueUnbound method of the MyObject instance is called when the session to which it is bound times out.
Answer: D
Q: 200 As a convenience feature, your web pages include an Ajax request every five minutes to a special servlet that monitors the age of the user's session. The client-side JavaScript that handles the Ajax callback displays a message on the screen as the session ages. The Ajax call does NOT pass any cookies, but it passes the session ID in a request parameter called sessionID. In addition, assume that your webapp keeps a hashmap of session objects by the ID. Here is a partial implementation of this servlet:
10. public class SessionAgeServlet extends HttpServlet {
11. public void service(HttpServletRequest request, HttpServletResponse) throws IOException {
12. String sessionID = request.getParameter("sessionID");
13. HttpSession session = getSession(sessionID);
14. long age = // your code here
15. response.getWriter().print(age);
16. }
... // more code here 47. }
Which code snippet on line 14, will determine the age of the session?
A. session.getMaxInactiveInterval();
B. session.getLastAccessed().getTime() - session.getCreationTime().getTime();
C. session.getLastAccessedTime().getTime() - session.getCreationTime().getTime();
D. session.getLastAccessed() - session.getCreationTime();
E. session.getMaxInactiveInterval() - session.getCreationTime();
F. session.getLastAccessedTime() - session.getCreationTime();
Answer: F
Q: 201 Which statement is true about web container session management?
A. Access to session-scoped attributes is guaranteed to be thread-safe by the web container.
B. To activate URL rewriting, the developer must use the HttpServletResponse.setURLRewriting method.
C. If the web application uses HTTPS, then the web container may use the data on the HTTPS request stream to identify the client.
D. The JSESSIONID cookie is stored permanently on the client so that a user may return to the web application and the web container will rejoin that session.
Answer: C
Q: 202 You are designing an n-tier Java EE application. You have already decided that some of your JSPs will need to get data from a Customer entity bean. You are trying to decide whether to use a Customer stub object or a Transfer Object. Which two statements are true? (Choose two.)
A. The stub will increase network traffic.
B. The Transfer Object will decrease data staleness.
C. The stub will increase the logic necessary in the JSPs.
D. In both cases, the JSPs can use EL expressions to get data.
E. Only the Transfer Object will need to use a Business Delegate.
F. Using the stub approach allows you to design the application without using a Service Locator.
Answer: A, D
Q: 203 Which two are characteristics of the Intercepting Filter pattern? (Choose two.)
A. It provides centralized request handling for incoming requests.
B. It forces resource authentication to be distributed across web components.
C. It reduces coupling between presentation-tier clients and underlying business services.
D. It can be added and removed unobtrusively, without requiring changes to existing code.
E. It allows preprocessing and postprocessing on the incoming requests and outgoing responses.
Answer: D, E
Q: 204 A developer has created a web application that includes a servlet for each use case in the application. These servlets have become rather difficult to maintain because the request processing methods have become very large. There is also common processing code in many servlets because these use cases are very similar. Which two design patterns can be used together to refactor and simplify this web application? (Choose two.)
A. Proxy
B. View Helper
C. F ront Controller
D. Session Facade
E. Business Delegate
F. Model-View-Controller
Answer: C, F
Q: 205 A developer is designing a multi-tier web application and discovers a need to hide the details of establishing and maintaining remote communications from the client. In addition, the application needs to find, in a transparent manner, the heterogeneous business components used to service the client's requests. Which design patterns, working together, address these issues?
A. Business Delegate and Transfer Object
B. Business Delegate and Service Locator
C. Front Controller and Business Delegate
D. Intercepting Filter and Transfer Object
E. Model-View-Controller and Intercepting Filter
Answer: B
Q: 206 A developer is designing a web application that must support multiple interfaces, including:
an XML web service for B2B HTML for web-based clients WML for wireless customers
Which design pattern provides a solution for this problem?
A. Session Facade
B. Business Delegate
C. Data Access Object
D. Model-View-Controller
E. Chain of Responsibility
Answer: D
Q: 207 A developer is designing a web application which extensively uses EJBs and JMS. The developer finds that there is a lot of duplicated code to build the JNDI contexts to access the beans and queues. Further, because of the complexity, there are numerous errors in the code. Which J2EE design pattern provides a solution for this problem?
B. Transfer Object
C. Service Locator
D. Session Facade
E. Business Delegate
F. Data Access Object
Answer: C
Q: 208 A developer is designing a web application that must support multiple interfaces, including:
an XML web service for B2B HTML for web-based clients WML for wireless customers
Which design pattern provides a solution for this problem?
A. Session Facade
B. Business Delegate
C. Data Access Object
D. Model-View-Controller
E. Chain of Responsibility
Answer: D
Q: 209 Which two are characteristics of the Front Controller pattern? (Choose two.)
A. It simplifies remote interfaces to distributed objects.
B. It promotes cleaner application partitioning and encourages reuse.
C. It provides an initial point of contact for handling all related requests.
D. It reduces maintainability due to the increased complexity of the design.
E. It provides loosely coupled handlers that can be combined in various permutations.
Answer: B, C
A. Transfer Object
B. Service Locator
C. Intercepting Filter
D. Business Delegate
Answer: D