Q: 151 Click the Task button.
Place the code snippets in the
proper order to construct the JSP code to include dynamic content into a JSP
page at request-time.
Answer: Check ExamWorx eEngine, Download from Member
Center
Q: 152 Given:
6. <% int[] nums = {42, 420, 4200};
7.
request.setAttribute("foo",
nums); %>
Which two successfully translate and result in a value
of true? (Choose two.)
B. ${requestScope[foo][0] > 500}
C. ${requestScope['foo'][1] = 420}
D. ${(requestScope['foo'][0] lt 50) && (3 gt 2)}
Answer: A, D
Q: 153 Click the Exhibit button.
Given:
11. <% com.example.Advisor advisor = new
com.example.Advisor(); %>
12. <% request.setAttribute("foo", advisor);
%>
Assuming there are no other "foo"
attributes in the web application, which three are valid EL expressions for
retrieving the advice property of advisor? (Choose three.)
B. ${request.foo.advice}
C. ${requestScope.foo.advice}
D. ${requestScope[foo[advice]]}
E. ${requestScope["foo"]["advice"]}
F. ${requestScope["foo"["advice"]]}
Answer: A, C, E
Q: 154 You are
creating an error page that provides a user-friendly screen whenever a server
exception occurs. You want to hide the stack trace, but you do want to provide
the exception's error message to the user so the user can provide it to the
customer service agent at your company. Which EL code snippet inserts this
error message into the error page?
A. Message: <b>${exception.message}</b>
B. Message: <b>${exception.errorMessage}</b> C. M essage: <b>${request.exception.message}</b>
D. Message: <b>${pageContext.exception.message}</b>
E. Message: <b>${request.exception.errorMessage}</b>
F. Message: <b>${pageContext.exception.errorMessage}</b>
Answer: D
Q: 155 You are
building a dating web site. The client's date of birth is collected along with
lots of other information. You have created an EL function with the signature:
calcAge(java.util.Date):int and it is assigned to the name, age, in the
namespace, funct. In one of your JSPs you need to print a special message to
clients who are younger than 25. Which EL code snippet will return true for
this condition?
B. ${calcAge[client.birthDate] < 25}
C. ${funct:age(client.birthDate) < 25}
D. ${funct:age[client.birthDate] < 25}
E. ${funct:calcAge(client.birthDate) < 25}
F. ${funct:calcAge[client.birthDate] < 25}
Answer: C
Q: 156 Given:
11. <% java.util.Map map = new java.util.HashMap();
12.
request.setAttribute("map",
map);
13.
map.put("a",
"b");
14.
map.put("b",
"c");
15.
map.put("c",
"d"); %>
16. <%-- insert code here --%>
Which three EL expressions, inserted at line 16, are
valid and evaluate to "d"? (Choose three.)
A. ${map.c}
B. ${map[c]} C. ${map["c"]}
D. ${map.map.b}
E. ${map[map.b]}
F. ${map.(map.b)}
Answer: A, C, E
Q: 157 Assume the tag handler for
a st:simple tag extends SimpleTagSupport. In what way can scriptlet code be
used in the body of st:simple?
A.
set
the body content type to JSP in the TLD
B.
Scriptlet
code is NOT legal in the body of st:simple.
C.
add
scripting-enabled="true" to the start tag for the st:simple element
D.
add
a pass-through Classic tag with a body content type of JSP to the body of
st:simple, and place the scriptlet code in the body of that tag
Answer: B
www.ExamWorx.com Q: 158 Which
statement is true if the doStartTag method returns EVAL_BODY_BUFFERED ?
A.
The
tag handler must implement BodyTag.
B.
The
doAfterBody method is NOT called.
C.
The
setBodyContent method is called once.
D.
It
is never legal to return EVAL_BODY_BUFFERED from doStartTag.
Answer: C
Q: 159 You are
creating a library of custom tags that mimic the HTML form tags. When the user
submits a form that fails validation, the JSP form is forwarded back to the
user. The <t:textField> tag must support the ability to re-populate the
form field with the request parameters from the user's last request. For
example, if the user entered "Samantha" in the text field called
firstName, then the form is re-populated like this:
<input type='text' name='firstName' value='Samantha'
/>
Which tag handler method will accomplish this goal?
A. public int doStartTag() throws JspException { JspContext ctx = getJspContext();
String value = ctx.getParameter(this.name); if ( value == null ) value = "";
JspWriter out = pageContext.getOut(); try {
out.write(String.format(INPUT, this.name, value)); } (Exception e) { throw new JspException(e); } return SKIP_BODY;
}
private static String INPUT
= "<input type='text' name='%s' value='%s' />"; B. public void doTag() throws JspException { JspContext ctx = getJspContext();
String value = ctx.getParameter(this.name); if ( value == null ) value = "";
JspWriter out = pageContext.getOut(); try {
out.write(String.format(INPUT, this.name, value)); } (Exception e) { throw new JspException(e); }
}
private static String INPUT = "<input type='text' name='%s' value='%s' />";
C. public int doStartTag() throws JspException { ServletRequet request = pageContext.getRequest(); String value = request.getParameter(this.name);
if ( value == null ) value = ""; JspWriter out = pageContext.getOut(); try {
out.write(String.format(INPUT, this.name, value)); } (Exception e) { throw new JspException(e); } return SKIP_BODY;
}
private static String INPUT = "<input type='text' name='%s' value='%s' />";
D. public void doTag() throws JspException { ServletRequet request = pageContext.getRequest(); String value = request.getParameter(this.name);
if ( value == null ) value = ""; JspWriter out = pageContext.getOut(); try {
out.write(String.format(INPUT, this.name, value)); } (Exception e) { throw new JspException(e); }
}
private static String INPUT = "<input type='text' name='%s' value='%s' />";
Answer: C
Q: 160 Which two directives are
applicable only to tag files? (Choose two.)
B. page
C. taglib
D. include
E. variable
Answer: A, E
Q: 161 The tl:taskList and tl:task tags output a set of tasks to the response
and are used as follows:
11. <tl:taskList>
12. <tl:task name="Mow the lawn" />
13. <tl:task name="Feed the dog" />
14. <tl:task name="Do the laundry" />
15. </tl:taskList>
The
tl:task tag supplies information about a single task while the tl:taskList tag
does the final output. The tag handler for tl:taskList is TaskListTag. The tag
handler for tl:task is TaskTag. Both tag handlers extend BodyTagSupport.
Which allows the tl:taskList tag to get the task names
from its nested tl:task children?
A. It is impossible for a tag handler that extends BodyTagSupport to communicate with its parent and child tags.
B. In the TaskListTag.doStartTag method, call super.getChildTags() and iterate through the results. Cast each result to a TaskTag and call getName().
C. In the TaskListTag.doStartTag method, call getChildTags() on the PageContext and iterate through the results. Cast each result to a TaskTag and call getName().
D. Create an addTaskName method in TaskListTag. Have the TaskListTag.doStartTag method, return BodyTag.EVAL_BODY_BUFFERED. In the TaskTag.doStartTag method, call super.getParent(), cast it to a TaskListTag, and call addTaskName().
E. Create an addTaskName method in TaskListTag. Have the TaskListTag.doStartTag method, return BodyTag.EVAL_BODY_BUFFERED. In the TaskTag.doStartTag method, call findAncestorWithClass() on the PageContext, passing TaskListTag as the class to find. Cast the result to TaskListTag and call addTaskName().
Answer: D
Q: 162 Click the Exhibit button.
Given:
10. <form action='create_product.jsp'>
11. Product Name: <input type='text'
name='prodName'/><br/>
12. Product Price: <input type='text'
name='prodPrice'/><br/>
13. </form>
For a given product instance,
which three jsp:setProperty attributes must be used to initialize its
properties from the HTML form? (Choose three.)
A. id
B. name
C. type
D. param
E. property
F. reqParam
G. attribute
Answer: B, D, E
Q: 163 Given:
1. package com.example;
2.
3. public abstract class AbstractItem {
4. private String name;
...
13. }
Assume a concrete class com.example.ConcreteItem
extends com.example.AbstractItem. A servlet sets a session-scoped attribute
called "item" that is an instance of com.example.ConcreteItem and
then forwards to a JSP page.
Which two are valid standard
action invocations that expose a scripting variable to the JSP page? (Choose
two.)
B. <jsp:useBean id="item" type="com.example.ConcreteItem" scope="session" />
C. <jsp:useBean id="item" class="com.example.ConcreteItem" scope="session" />
D. <jsp:useBean id="item" type="com.example.ConcreteItem" class="com.example.AbstractItem"
scope="session" />
Answer: B, C
Q: 164 Your web
application views all have the same header, which includes the <title>
tag in the <head> element of the rendered HTML. You have decided to
remove this redundant HTML code from your JSPs and put it into a single JSP
called /WEB-INF/jsp/header.jsp. However, the title of each page is unique, so
you have decided to use a variable called pageTitle to parameterize this in the
header JSP, like this:
10. <title>${param.pageTitle}<title>
Which JSP code snippet should you
use in your main view JSPs to insert the header and pass the pageTitle
variable?
A. <jsp:insert page='/WEB-INF/jsp/header.jsp'> ${pageTitle='Welcome Page'}
</jsp:insert>
B. <jsp:include page='/WEB-INF/jsp/header.jsp'> ${pageTitle='Welcome Page'}
</jsp:include>
C. <jsp:include file='/WEB-INF/jsp/header.jsp'> ${pageTitle='Welcome Page'}
</jsp:include>
D. <jsp:insert page='/WEB-INF/jsp/header.jsp'> <jsp:param name='pageTitle' value='Welcome Page' /> </jsp:insert>
E. <jsp:include page='/WEB-INF/jsp/header.jsp'> <jsp:param name='pageTitle' value='Welcome Page' /> </jsp:include>
Answer: E
Q: 165 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.)
B. <jsp:useBean id="product" class="com.example.Product" /> <%= product.getName() %>
C. <jsp:useBean id="com.example.Product" scope="page"> <%= product.getName() %>
</jsp:useBean>
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>
Answer: B, D
Q: 166 If you
want to use the Java EE platform's built-in type of authentication that uses a
custom HTML page for authentication, which two statements are true? (Choose
two.)
A. Your deployment descriptor will need to contain this tag: <auth-method>CUSTOM</auth-method>.
B. The related custom HTML login page must be named loginPage.html. C. When you use this type of authentication, SSL is turned on automatically.
D. You must have a tag in your deployment descriptor that allows you to point to both a login HTML page and an HTML page for handling any login errors.
E. In the HTML related to authentication for this application, you must use predefined variable names for the variables that store the user and password values.
Answer: D, E
Q: 167 Given the two security
constraints in a deployment descriptor:
101. <security-constraint>
102. <!--a correct url-pattern and http-method goes
here-->
103. <auth-constraint><role-name>SALES</role-name></auth-
103. <auth-constraint>
104.
<role-name>SALES</role-name>
105. </auth-constraint>
106. </security-constraint>
107. <security-constraint>
108. <!--a correct url-pattern and http-method goes
here-->
109. <!-- Insert an auth-constraint here -->
110. </security-constraint>
If the two security constraints
have the same url-pattern and http-method, which two, inserted independently at
line 109, will allow users with role names of either SALES or MARKETING to
access this resource? (Choose two.)
A. <auth-constraint/>
B. <auth-constraint> <role-name>*</role-name> </auth-constraint>
C. <auth-constraint><role-name>ANY</role-name> </auth-constraint>
D. <auth-constraint> <role-name>MARKETING</role-name> </auth-constraint>
Answer: B, D
Q: 168 Which two
are valid values for the <transport-guarantee> element inside a
<security-constraint> element of a web application deployment descriptor?
(Choose two.)
A. NULL
B. SECURE
C. INTEGRAL
D. ENCRYPTED
E. CONFIDENTIAL
Answer: C, E
Q: 169 Which
basic authentication type is optional for a J2EE 1.4 compliant web container?
A. HTTP Basic Authentication
B. Form Based Authentication
C. HTTP Digest Authentication
D. HTTPS Client Authentication
Answer: C
Q: 170 Which security mechanism uses
the concept of a realm?
B. data integrity
C. confidentiality
D. authentication
Answer: D
Q: 171 Which two security
mechanisms can be directed through a sub-element of the
<user-data-constraint> element in a web application deployment
descriptor? (Choose two.)
A. authorization
B. data integrity
C. confidentiality
D. authentication
Answer: B, C
Q: 172 You are
developing several tag libraries that will be sold for development of
third-party web applications. You are about to publish the first three
libraries as JAR files: container-tags.jar, advanced-html-form-tags.jar, and
basic-html-form-tags.jar. Which two techniques are appropriate for packaging
the TLD files for these tag libraries? (Choose two.)
A. The TLD must be located within the WEB-INF directory of the JAR file.
B. The TLD must be located within the META-INF directory of the JAR file.
C. The TLD must be located within the META-INF/tld/ directory of the JAR file.
D. The TLD must be located within a subdirectory of WEB-INF directory of the JAR file.
E. The TLD must be located within a subdirectory of META-INF directory of the JAR file.
F. The TLD must be located within a subdirectory of META-INF/tld/ directory of the JAR file.
Answer: B, E
Q: 173 A custom
tag is defined to take three attributes. Which two correctly invoke the tag
within a JSP page? (Choose two.)
A. <prefix:myTag a="foo" b="bar" c="baz" />
B. <prefix:myTag attributes={"foo","bar","baz"} />
C. <prefix:myTag jsp:attribute a="foo" b="bar" c="baz" />
D. <prefix:myTag> <jsp:attribute a:foo b:bar c:baz /> </prefix:myTag>
E. <prefix:myTag> <jsp:attribute ${"foo", "bar", "baz"} /> </prefix:myTag>
F. <prefix:myTag> <jsp:attribute a="foo" b="bar" c="baz"/> </prefix:myTag>
G. <prefix:myTag> <jsp:attribute name="a">foo</jsp:attribute>
<jsp:attribute name="b">bar</jsp:attribute> <jsp:attribute name="c">baz</jsp:attribute> </prefix:myTag>
Answer: A, G
Q: 174 In a
JSP-centric shopping cart application, you need to move a client's home address
of the Customer object into the shipping address of the Order object. The
address data is stored in a value object class called Address with properties
for: street address, city, province, country, and postal code. Which two JSP
code snippets can be used to accomplish this goal? (Choose two.)
A. <c:set var='order' property='shipAddress' value='${client.homeAddress}' />
B. <c:set target='${order}' property='shipAddress' value='${client.homeAddress}' />
C. <jsp:setProperty name='${order}' property='shipAddress' value='${client.homeAddress}' />
D. <c:set var='order' property='shipAddress'> <jsp:getProperty name='client' property='homeAddress' /> </c:store>
E. <c:set target='${order}' property='shipAddress'> <jsp:getProperty name='client' property='homeAddress' /> </c:set>
F. <c:setProperty name='${order}' property='shipAddress'> <jsp:getProperty name='client' property='homeAddress' /> </c:setProperty>
Answer: B, E
Q: 175 You have been contracted to create a web site for a free dating service.
One feature is the ability for one client to send a message to another client,
which is displayed in the latter client's private page. Your contract
explicitly states that security is a high priority. Therefore, you need to
prevent cross-site hacking in which one user inserts JavaScript code that is
then rendered and invoked when another user views that content. Which two JSTL
code snippets will prevent cross-site hacking in the scenario above? (Choose
two.)
20. <c:out>${message}</c:out>
21. <c:out value='${message}' />
22. <c:out value='${message}' escapeXml='true' />
23. <c:out eliminateXml='true'>${message}</c:out>
24. <c:out value='${message}' eliminateXml='true' />
Answer: B, C
Q: 176 Click the Exhibit button.
Assuming the tag library in the
exhibit is imported with the prefix forum, which custom tag invocation produces
a translation error in a JSP page?
B. <forum:message subject="My Subject"> My message body.</forum:message>
C. <forum:message from="My Name" subject="${param.subject}"> ${param.body}
</forum:message>
D. <forum:message from="My Name" subject="My Subject"> <%= request.getParameter( "body" ) %> </forum:message>
E. <forum:message from="My Name" subject="<%= request.getParameter( "subject" ) %>"> My message body. </forum:message>
Answer: D
Q: 177 Which JSTL
code snippet can be used to import content from another web resource?
B. <c:import page="foo.jsp"/>
C. <c:include url="foo.jsp"/>
D. <c:include page="foo.jsp"/>
E. Importing cannot be done in JSTL. A standard action must be used instead.
Answer: A
Q: 178 Click the Exhibit button.
Assume the tag library in the
exhibit is placed in a web application in the path /WEB-INF/tld/example.tld.
1.
2. <ex:hello />
Which JSP code, inserted at line 1, completes the JSP
code to invoke the hello tag?
B. <%@ taglib uri="/WEB-INF/tld/example.tld" %>
C. <%@ taglib prefix="ex" uri="http://localhost:8080/tld/example.tld" %>
D. <%@ taglib prefix="ex" uri="http://example.com/tld/example" %>
Answer: D
Q: 179 Which JSTL
code snippet produces the output "big number" when X is greater than
42, but outputs "small number" in all other cases?
A. <c:if test='<%= (X > 42) %>'> <c:then>big number</c:then> <c:else>small number</c:else> </c:if>
B. <c:if> <c:then test='<%= (X > 42) %>'>big number</c:then><c:else>small number</c:else> </c:if>
C. <c:choose test='<%= (X > 42) %>'> <c:then>big number</c:when> <c:else>small number</c:otherwise> </c:choose>
D. <c:choose test='<%= (X > 42) %>'> <c:when>big number</c:when> <c:otherwise>small number</c:otherwise> </c:choose>
E. <c:choose> <c:when test='<%= (X > 42) %>'>big number</c:when> <c:otherwise>small number</c:otherwise> </c:choose>
Answer: E
Q: 180 A
developer chooses to avoid using SingleThreadModel but wants to ensure that
data is updated in a thread-safe manner. Which two can support this design
goal? (Choose two.)
A. Store the data in a local variable.
B. Store the data in an instance variable.
C. Store the data in the HttpSession object.
D. Store the data in the ServletContext object.
E. Store the data in the ServletRequest object.
Answer: A, E
No comments :
Post a Comment