Saturday, 17 December 2011

SCWCD Questions 251 - 260


QUESTION NO: 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


QUESTION NO: 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


QUESTION NO: 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

QUESTION NO: 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


QUESTION NO: 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


QUESTION NO: 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


QUESTION NO: 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


QUESTION NO: 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


QUESTION NO: 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


QUESTION NO: 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

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...