최신 Java Technology 1Z0-858 무료샘플문제:
1. You need to retrieve the username cookie from an HTTP request. If this cookie does NOT exist, then the c variable will be null. Which code snippet must be used to retrieve this
cookie object?
A) 10. Cookie c = null;
11.
for ( Iterator i = request.getCookies();
12.
i.hasNext(); ) {
13.
Cookie o = (Cookie) i.next();
14.
if ( o.getName().equals("username") ) {
15.
c = o;
16.
break;
17.
}
18.
}
B) 10. Cookie c = request.getCookie("username");
C) 10. Cookie c = null;
11.
Cookie[] cookies = request.getCookies();
12.
for ( int i = 0; i < cookies.length; i++ ) {
13.
if ( cookies[i].getName().equals("username") ) {
14.
c = cookies[i];
15.
break;
16.
}
17.
}
D) 10. Cookie c = null;
11.
for ( Enumeration e = request.getCookies();
12.
e.hasMoreElements(); ) {
13.
Cookie o = (Cookie) e.nextElement();
14.
if ( o.getName().equals("username") ) {
15.
c = o;
16.
break;
17.
}
18.
}
2. Which method must be used to encode a URL passed as an argument to HttpServletResponse.sendRedirect when using URL rewriting for session tracking?
A) ServletResponse.encodeRedirectURL
B) HttpServletResponse.encodeURL
C) ServletResponse.encodeURL
D) HttpServletResponse.encodeRedirectURL
3. 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) Front Controller
B) Proxy
C) View Helper
D) Model-View-Controller
E) Session Facade
F) Business Delegate
4. Click the Exhibit button.
Given the JSP code:
1.<%
2.pageContext.setAttribute( "product",
3.new com.example.Product( "Pizza", 0.99 ) );
4.%>
5.<%-- insert code here --%>
Which two, inserted at line 5, output the name of the product in the response? (Choose
two.)
A) <jsp:useBean id="com.example.Product" scope="page">
<%= product.getName() %>
</jsp:useBean>
B) <jsp:useBean id="product" class="com.example.Product" />
<%= product.getName() %>
C) <%= product.getName() %>
D) <jsp:useBean id="product" type="com.example.Product"
scope="page" />
<%= product.getName() %>
E) <jsp:useBean id="product" type="com.example.Product">
<%= product.getName() %>
</jsp:useBean>
5. You are writing a JSP that includes scriptlet code to declare a List variable and initializes that variable to an ArrayList object. Which two JSP code snippets can you use to import these list types? (Choose two.)
A) <%@ import types='java.util.List' types='java.util.ArrayList' %>
B) <%@ page import='java.util.List'
import='java.util.ArrayList' %>
C) <%! import java.util.*; %>
D) <%@ import types='java.util.List,java.util.ArrayList' %>
E) <%! import java.util.List; import java.util.ArrayList; %>
F) <%@ page import='java.util.List,java.util.ArrayList' %>
질문과 대답:
질문 # 1 정답: C | 질문 # 2 정답: D | 질문 # 3 정답: A,D | 질문 # 4 정답: B,D | 질문 # 5 정답: B,F |