SCWCD(310-083) 250~276------完!

来源:互联网 发布:freefrom是什么软件 编辑:程序博客网 时间:2024/05/17 09:09

Q: 251 Which two are true about the JSTL core iteration custom tags? (Choose
two.)
A. It may iterate over arrays, collections, maps, and strings.
B. The body of the tag may contain EL code, but not scripting code.
C. When looping over collections, a loop status object may be used in the tag body.
D. It may iterate over a map, but only the key of the mapping may be used in the tag body.
E. When looping over integers (for example begin='1' end='10'), a loop status object may not be used in the tag
body.
Answer: A, C
解析:JSTL用<c:forEach>递归输出内容
forEach的配置:<body-content>JSP</body-content>
B.标签体可以使用EL和scripting
D.可以输出key,或者和value一起输出
E.可以不用标记,而把所有的值一起输出

Q: 252 Which two are valid and equivalent? (Choose two.)
A. <%! int i; %>
B. <%= int i; %>
C. <jsp:expr>int i;</jsp:expr>
D. <jsp:scriptlet>int i;</jsp:scriptlet>
E. <jsp:declaration>int i;</jsp:declaration>
Answer: A, E
解析:
<%!int i;%>等价于<jsp:declaration>声明变量
<jsp:expression>用于表达式
<jsp:scriptlet>用于scriptlet
<jsp:text>用于嵌入文本

Q: 253 The JSP developer wants a comment to be visible in the final output to the
browser. Which comment style needs to be used in a JSP page?
A.<!-- this is a comment -->
B.<% // this is a comment %>
C.<%-- this is a comment --%>
D.<% /** this is a comment **/ %>
Answer: A
解析:
<!--xxx-->html式注解,客户端可见
<%--xxx-->jsp式注解,客户端不可见

Q: 254 Which is a benefit of precompiling a JSP page?
A.It avoids initialization on the first request.
B.It provides the ability to debug runtime errors in the application.
C.It provides better performance on the first request for the JSP page.
D.It avoids execution of the _jspService method on the first request.
Answer: C
解析:JSP预编译(为Servlet),使JSP页面加载时,更好表现内容

Q: 255 Given tutorial.jsp:
2. <h1>EL Tutorial</h1>
3. <h2>Example 1</h2>
4. <p>
5. Dear ${my:nickname(user)}
6. </p>
Which, when added to the web application deployment descriptor, ensures that line 5 is included
verbatim in the JSP output?
A. <jsp-config>
    <url-pattern>*.jsp</url-pattern>
    <el-ignored>true</el-ignored>
   </jsp-config>
B. <jsp-config>
    <url-pattern>*.jsp</url-pattern>
    <isELIgnored>true</isELIgnored>
   </jsp-config>
C. <jsp-config>
    <jsp-property-group>
    <el-ignored>*.jsp</el-ignored>
    </jsp-property-group>
   </jsp-config>
D. <jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <el-ignored>true</el-ignored>
    </jsp-property-group>
   </jsp-config>
E. <jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <isElIgnored>true</isElIgnored>
    </jsp-property-group>
   </jsp-config>
Answer: D
解析:
<jsp-property-group>对多个具有相同属性的JSP统一定义
<url-pattern>设置值所影响的范围
<el-ignored>若为true表示不支持EL表达式

Q: 256 In a JSP-centric web application, you need to create a catalog browsing
JSP page. The catalog is stored as a List object in the catalog attribute of the webapp's ServletContext
object. Which scriptlet code snippet gives you access to the catalog object?
A.<% List catalog = config.getAttribute("catalog"); %>
B.<% List catalog = context.getAttribute("catalog"); %>
C.<% List catalog = application.getAttribute("catalog"); %>
D.<% List catalog = servletContext.getAttribute("catalog"); %>
Answer: C
解析:JSP的application即Servlet的ServletContext。

Q: 257 You are building your own layout mechanism by including dynamic
content for the page's header and footer sections. The footer is always static, but the header generates the
<title> tag that requires the page name to be specified dynamically when the header is imported. Which
JSP code snippet performs the import of the header content?
A. <jsp:include page='/WEB-INF/jsp/header.jsp'>
    <jsp:param name='pageName' value='Welcome Page' />
   </jsp:include>
B. <jsp:import page='/WEB-INF/jsp/header.jsp'>
    <jsp:param name='pageName' value='Welcome Page' />
   </jsp:import>
C. <jsp:include page='/WEB-INF/jsp/header.jsp'>
    <jsp:attribute name='pageName' value='Welcome Page' />
   </jsp:include>
D. <jsp:import page='/WEB-INF/jsp/header.jsp'>
    <jsp:attribute name='pageName' value='Welcome Page' />
   </jsp:import>
Answer: A
解析:
<jsp:include page=''>动态加载页面
<jsp:param name='' value=''>设置参数

Q: 258 Which ensures that a JSP response is of type "text/plain"?
A.<%@ page mimeType="text/plain" %>
B.<%@ page contentType="text/plain" %>
C.<%@ page pageEncoding="text/plain" %>
D.<%@ page contentEncoding="text/plain" %>
E.<% response.setEncoding("text/plain"); %>
F.<% response.setMimeType("text/plain"); %>
Answer: B
解析:
<%@ page contentType=''%>设置整个页面的编码类型
<% response.contentType=''%>设置响应的编码

Q: 259 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
解析:只有接收页面才能读取参数属性,可以该属性放在request或者URL路径后面。

Q: 260 All of your JSPs need to have a link that permits users to email the web
master. This web application is licensed to many small businesses, each of which have a different email
address for the web master. You have decided to use a context parameter that you specify in the
deployment descriptor, like this:
42. <context-param>
43. <param-name>webmasterEmail</param-name>
44. <param-value>master@example.com</param-value>
45. </context-param>
Which JSP code snippet creates this email link?
A.<a href='mailto:${contextParam.webmasterEmail}'>contact us</a>
B.<a href='mailto:${applicationScope.webmasterEmail}'>contact us</a>
C.<a href='mailto:${contextInitParam.webmasterEmail}'>contact us</a>
D.<a href='mailto:${initParam.webmasterEmail}'>contact us</a>
Answer: D
解析:EL获取<context-param>中的属性:${initParam.name}

Q: 261 Which three are true about servlet filters? (Choose three.)
A. A filter must implement the destroy method.
B. A filter must implement the doFilter method.
C. A servlet may have multiple filters associated with it.
D. A servlet that is to have a filter applied to it must implement the javax.servlet.FilterChain interface.
E. A filter that is part of a filter chain passes control to the next filter in the chain by invoking the
FilterChain.forward method.
F. For each <filter> element in the web application deployment descriptor, multiple instances of a filter may be
created by the web container.
Answer: A, B, C
解析:
filter文件必须实现destroy().doFilter().init()
E.执行下一个过滤器,filterChain.doFilter()
F.一个filter只有一个实例

Q: 262 Click the Task button.
Place the XML elements in the web application deployment descriptor solution to configure a servlet
context event listener named com.example.MyListener.
Answer: Check ExamWorx eEngine, Download from Member Center


解析:监听器格式
 <listener>
  <listener-class></listener-class>
 </listener>

Q: 263 Which is true about the web container request processing model?
A. The init method on a filter is called the first time a servlet mapped to that filter is invoked.
B. A filter defined for a servlet must always forward control to the next resource in the filter chain.
C. Filters associated with a named servlet are applied in the order they appear in the web application
deployment descriptor file.
D. If the init method on a filter throws an UnavailableException, then the container will make no further
attempt to execute it.
Answer: C
解析:filter按部署文件web.xml中的顺序执行

Q: 264 Your IT department is building a lightweight Front Controller servlet that
invokes an application logic object with the interface:
public interface ApplicationController {
public String invoke(HttpServletRequest request)
}
The return value of this method indicates a symbolic name of the next view. From this name, the Front
Controller servlet looks up the JSP URL in a configuration table. This URL might be an absolute path or
a path relative to the current request. Next, the Front Controller servlet must send the request to this JSP
to generate the view. Assume that the servlet variable request is assigned the current HttpServletRequest
object and the variable context is assigned the webapp's ServletContext.
Which code snippet of the Front Controller servlet accomplishes this goal?
A. Dispatcher view = context.getDispatcher(viewURL);
   view.forwardRequest(request, response);
B. Dispatcher view = request.getDispatcher(viewURL);
   view.forwardRequest(request, response);
C. RequestDispatcher view = context.getRequestDispatcher(viewURL);
   view.forward(request, response);
D. RequestDispatcher view = request.getRequestDispatcher(viewURL);
   view.forward(request, response);
Answer: D
解析:
HttpServletRequest.getRequestDispatcher(parh)返回地址资源
RequestDispatcher.forward(r,r)传递到该地址

Q: 265 Given that a web application consists of two HttpServlet classes, ServletA
and ServletB, and the ServletA.service method:
20. String key = "com.example.data";
21. session.setAttribute(key, "Hello");
22. Object value = session.getAttribute(key);
23.
Assume session is an HttpSession, and is not referenced anywhere else in ServletA.
Which two changes, taken together, ensure that value is equal to "Hello" on line 23? (Choose two.)
A. ensure that the ServletB.service method is synchronized
B. ensure that the ServletA.service method is synchronized
C. ensure that ServletB synchronizes on the session object when setting session attributes
D. enclose lines 21-22 in a synchronized block:
synchronized(this) {
    session.setAttribute(key, "Hello");
    value = session.getAttribute(key);
}
E. enclose lines 21-22 in a synchronized block:
synchronized(session) {
    session.setAttribute(key, "Hello");
    value = session.getAttribute(key);
}
Answer: C, E
解析:给session加同步锁

Q: 266 Which retrieves all cookies sent in a given HttpServletRequest request?
A.request.getCookies()
B.request.getAttributes()
C.request.getSession().getCookies()
D.request.getSession().getAttributes()
Answer: A
解析:从request中获取所有cookie方法:getCookies()

Q: 267 Your company has a corporate policy that prohibits storing a customer's
credit card number in any corporate database. However, users have complained that they do NOT want
to re-enter their credit card number for each transaction. Your management has decided to use
client-side cookies to record the user's credit card number for 120 days. Furthermore, they also want to
protect this information during transit from the web browser to the web container; so the cookie must
only be transmitted over HTTPS. Which code snippet creates the "creditCard" cookie and adds it to the
out going response to be stored on the user's web browser?
A. 10. Cookie c = new Cookie("creditCard", usersCard);
   11. c.setSecure(true);
   12. c.setAge(10368000);
   13. response.addCookie(c);
B. 10. Cookie c = new Cookie("creditCard", usersCard);
   11. c.setHttps(true);
   12. c.setMaxAge(10368000);
   13. response.setCookie(c);
C. 10. Cookie c = new Cookie("creditCard", usersCard);
   11. c.setSecure(true);
   12. c.setMaxAge(10368000);
   13. response.addCookie(c);
D. 10. Cookie c = new Cookie("creditCard", usersCard);
   11. c.setHttps(true);
   12. c.setAge(10368000);
   13. response.addCookie(c);
E. 10. Cookie c = new Cookie("creditCard", usersCard);
   11. c.setSecure(true);
   12. c.setAge(10368000);
   13. response.setCookie(c);
Answer: C
解析:(同63)
setSecure设置cookie是否通过安全通道传送
setMagAge设置cookie的生命周期
addCookie添加cookie

Q: 268 Click the Task button.
Given a servlet mapped to /control, place the correct URI segment returned as a String on the
corresponding HttpServletRequest method call for the URI: /myapp/control/processorder.
Answer: Check ExamWorx eEngine, Download from Member Center


解析:(同60)
servlet mapped to /control所以getServletPath为/control
getContext为/myapp,getPathInfo为/processorder

Q: 269 A web browser need NOT always perform a complete request for a
particular page that it suspects might NOT have changed. The HTTP specification provides a mechanism
for the browser to retrieve only a partial response from the web server; this response includes
information, such as the Last-Modified date but NOT the body of the page. Which HTTP method will the
browser use to retrieve such a partial response?
A.GET
B.ASK
C.SEND
D.HEAD
E.TRACE
F.OPTIONS
Answer: D
解析:HTTP的HEAD方法获取http的头部信息

Q: 270 You are creating a servlet that generates stock market graphs. You want to
provide the web browser with precise information about the amount of data being sent in the response
stream. Which two HttpServletResponse methods will you use to provide this information? (Choose
two.)
A.response.setLength(numberOfBytes);
B.response.setContentLength(numberOfBytes);
C.response.setHeader("Length", numberOfBytes);
D.response.setIntHeader("Length", numberOfBytes);
E.response.setHeader("Content-Length", numberOfBytes);
F.response.setIntHeader("Content-Length", numberOfBytes);
Answer: B, F
解析:HttpServletResponse设置内容长度
setContentLength(int len)or setIntHeader("Content-Length",int len)

Q: 271 Which two prevent a servlet from handling requests? (Choose two.)
A.The servlet's init method returns a non-zero status.
B.The servlet's init method throws a ServletException.
C.The servlet's init method sets the ServletResponse's content length to 0.
D.The servlet's init method sets the ServletResponse's content type to null.
E.The servlet's init method does NOT return within a time period defined by the servlet container.
Answer: B, E
解析:阻止一个servlet处理请求的方法,在init方法中抛出异常或者init方法不返回内容并设置时间点

Q: 272 A web application allows the HTML title banner to be set using a servlet
context initialization parameter called titleStr. Which two properly set the title in this scenario? (Choose
two.)
A.<title>${titleStr}</title>
B.<title>${initParam.titleStr}</title>
C.<title>${params[0].titleStr}</title>
D.<title>${paramValues.titleStr}</title>
E.<title>${initParam['titleStr']}</title>
F.<title>${servletParams.titleStr}</title>
G.<title>${request.get("titleStr")}</title>
Answer: B, E
解析:获取<context-param>中的值${initParam.name}或${initParam['name']

Q: 273 You are building a dating service web site. Part of the form to submit a
client's profile is a group of radio buttons for the person's hobbies:
20. <input type='radio' name='hobbyEnum' value='HIKING'>Hiking <br>
21. <input type='radio' name='hobbyEnum' value='SKIING'>Skiing <br>
22. <input type='radio' name='hobbyEnum' value='SCUBA'>SCUBA Diving
23. <!-- and more options -->
After the user submits this form, a confirmation screen is displayed with these hobbies listed. Assume
that an application-scoped variable, hobbies, holds a map between the Hobby enumerated type and the
display name.
Which EL code snippet will display Nth element of the user's selected hobbies?
A.${hobbies[hobbyEnum[N]}
B.${hobbies[paramValues.hobbyEnum[N]]}
C.${hobbies[paramValues@'hobbyEnum'@N]}
D.${hobbies.get(paramValues.hobbyEnum[N])}
E.${hobbies[paramValues.hobbyEnum.get(N)]}
Answer: B
解析:EL的paramValues获取数组的参数。[]访问数组或者链表元素

Q: 274 Given a web application in which the request parameter productID
contains a product identifier. Which two EL expressions evaluate the value of the productID? (Choose
two.)
A.${productID}
B.${param.productID}
C.${params.productID}
D.${params.productID[1]}
E.${paramValues.productID}
F.${paramValues.productID[0]}
G.${pageContext.request.productID}
Answer: B, F
解析:EL的param获取单一变量的参数,paramValues获取数组的参数。

Q: 275 You are building a web application with a scheduling component. On the
JSP, you need to show the current date, the date of the previous week, and the date of the next week. To
help you present this information, you have created the following EL functions in the 'd' namespace:
name: curDate; signature: java.util.Date currentDate()
name: addWeek; signature: java.util.Date addWeek(java.util.Date, int)
name: dateString; signature: java.util.String getDateString(java.util.Date)
Which EL code snippet will generate the string for the previous week?
A.${d:dateString(addWeek(curDate(), -1))}
B.${d:dateString[addWeek[curDate[], -1]]}
C.${d:dateString[d:addWeek[d:curDate[], -1]]}
D.${d:dateString(d:addWeek(d:curDate(), -1))}
Answer: D
解析:上一周d:addWeek(d:curDate(),-1),必须带有命名空间

Q: 276 You are building a dating web site. The client's date of birth is collected
along with lots of other information. The Person class has a derived method, getAge():int, which returns
the person's age calculated from the date of birth and today's date. In one of your JSPs you need to print
a special message to clients within the age group of 25 through 35. Which two EL code snippets will
return true for this condition? (Choose two.)
A.${client.age in [25,35]}
B.${client.age between [25,35]}
C.${client.age between 25 and 35}
D.${client.age <= 35 && client.age >= 25}
E.${client.age le 35 and client.age ge 25}
F.${not client.age > 35 && client.age < 25}
Answer: D, E
解析:le(less than)等于<=,gt(great then)等价>=

原创粉丝点击