QUESTION NO: 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
QUESTION NO: 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
QUESTION NO: 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
QUESTION NO: 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
QUESTION NO: 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
QUESTION NO: 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
QUESTION NO: 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
QUESTION NO: 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
QUESTION NO: 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?
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
QUESTION NO: 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
No comments:
Post a Comment