SCWCD 310-083 试题库由资深IT认证讲师和 SCWCD 产品专家结合 PROMETRIC 或 VUE 的真实考试环境最新原题倾心打造.
题库覆盖了当前最新的真实考题,并且全部附有正确答案,我们承诺题库对 SCWCD 310-083(Sun Certified Web Component Developer for J2EE 5)考试原题完整覆盖.310-083 题库 助您轻松通过认证考试,一次不过全额退款. 详情请登录 http://www.testpassport.cn/SCWCD/310-083.asp 查询
1.You are creating a JSP page to display a collection of data. This data can be displayed in several
different ways so the architect on your project decided to create a generic servlet that generates a
commadelimited
string so that various pages can render the data in different ways. This servlet takes on
request parameter: objectID.
Assume that this servlet is mapped to the URL pattern: /WEBINF/
data.
In the JSP you are creating, you need to split this string into its elements separated by commas and
generate an HTML <ul> list from the data.
Which JSTL code snippet will accomplish this goal?
A. <c:import varReader='dataString' url='/WEBINF/
data'>
<c:param name='objectID' value='${currentOID}' />
</c:import>
<ul>
<c:forTokens items'${dataString.split(",")}' var='item'>
<li>${item}</li>
</c:forTokens>
</ul>
B. <c:import varReader='dataString' url='/WEBINF/
data'>
<c:param name='objectID' value='${currentOID}' />
</c:import>
<ul>
<c:forTokens items'${dataString}' delims=',' var='item'>
<li>${item}</li>
</c:forTokens>
</ul>
C. <c:import var='dataString' url='/WEBINF/
data'>
<c:param name='objectID' value='${currentOID}' />
</c:import>
<ul>
<c:forTokens items'${dataString.split(",")}' var='item'>
<li>${item}</li>
</c:forTokens>
</ul>
D. <c:import var='dataString' url='/WEBINF/
data'>
<c:param name='objectID' value='${currentOID}' />
</c:import>
<ul>
<c:forTokens items'${dataString}' delims=',' var='item'>
<li>${item}</li>
</c:forTokens>
</ul>
Answer:D
2.You web application uses a lot of Java enumerated types in the domain model of the application. Built
into each enum type is a method, getDisplay(), which returns a localized, useroriented
string. There are
many uses for presenting enums within the web
application,
so your manager has asked you to create a custom tag that iterates over the set of enum values and
processes
the body of the tag once for each value; setting the value into a pagescoped
attribute called, enumValue.
Here is an example of how this tag is used:
10: <select name='season'>
11: <t:everyEnum type='com.example.Season'>
12: <option value='${enumValue}'>${enumValue.display}</option>
13: </t:everyEnum>
14: </select>
You have decided to use the Simple tag model to create this tag handler.
Which tag handler method will
accomplish this goal?
A. public void doTag() throw JspException {
try {
for ( Enum value : getEnumValues() ) {
pageContext.setAttribute("enumValue", value);
getJspBody().invoke(getOut());
}
} (Exception e) { throw new JspException(e); }
}
B. public void doTag() throw JspException {
try {
for ( Enum value : getEnumValues() ) {
getJspContext().setAttribute("enumValue", value);
getJspBody().invoke(null);
}
} (Exception e) { throw new JspException(e); }
}
C. public void doTag() throw JspException {
try {
for ( Enum value : getEnumValues() ) {
getJspContext().setAttribute("enumValue", value);
getJspBody().invoke(getJspContext().getWriter());
}
} (Exception e) { throw new JspException(e); }
}
D. public void doTag() throw JspException {
try {
for ( Enum value : getEnumValues() ) {
pageContext.setAttribute("enumValue", value);
getJspBody().invoke(getJspContext().getWriter());
}
} (Exception e) { throw new JspException(e); }
}
Answer:B
3.Which two are characteristics of the Service Locator pattern? (Choose two.)
A. It encapsulates component lookup procedures.
B. It increases source code duplication and decreases reuse.
C. It improves client performance by caching context and factory objects.
D. It degrades network performance due to increased access to distributed lookup services.
Answer:AC
4.Which three are valid URL mappings to a servlet in a web deployment descriptor? (Choose three.)
A. */*
B. *.do
C. MyServlet
D. /MyServlet
E. /MyServlet/*
F. MyServlet/*.jsp
Answer:BDE
5.Which two are true regarding a web application class loader? (Choose two.)
A. A web application may override the web container's implementation classes.
B. A web application running in a J2EE product may override classes in the javax.* namespace.
C. A web application class loader may NOT override any classes in the java.* and javax.* namespaces.
D. Resources in the WAR class directory or in any of the JAR files within the library directory may be
accessed using the J2SE semantics of getResource.
E. Resources in the WAR class directory or in any of the JAR files within the library directory CANNOT
be accessed using the J2SE semantics of getResource.
Answer: CD
6.Which three are true about the HttpServletRequestWrapper class? (Choose three.)
A. The HttpServletRequestWrapper is an example of the Decorator pattern.
B. The HttpServletRequestWrapper can be used to extend the functionality of a servlet request.
C. A subclass of HttpServletRequestWrapper CANNOT modify the behavior of the getReader method.
D. An HttpServletRequestWrapper may be used only by a class implementing the javax.servlet.Filter
interface.
E. An HttpServletRequestWrapper CANNOT be used on the request passed to the
RequestDispatcher.include method.
F. An HttpServletRequestWrapper may modify the header of a request within an object implementing
the javax.servlet.Filter interface.
Answer: ABF
7.Given an HttpServletRequest request and an HttpServletResponse response:
41: HttpSession session = null;
42: // insert code here
43: if(session == null) {
44: // do something if session does not exist
45: } else {
46: // do something if session exists
47: }
To implement the design intent, which statement must be inserted at line 42?
A. session = response.getSession();
B. session = request.getSession();
C. session = request.getSession(true);
D. session = request.getSession(false);
E. session = request.getSession("jsessionid");
Answer:D
8. Given:
3: class MyServlet extends HttpServlet {
4: public void doPut(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException {
5: // servlet code here
...
26: }
27: }
If the DD contains a single security constraint associated with MyServlet and its only <httpmethod>
tags
and <authconstraint>
tags are:
<httpmethod>
GET</httpmethod>
<httpmethod>
PUT</httpmethod>
<authconstraint>
Admin</authconstraint>
Which four requests would be allowed by the container? (Choose four.)
A. A user whose role is Admin can perform a PUT.
B. A user whose role is Admin can perform a GET.
C. A user whose role is Admin can perform a POST.
D. A user whose role is Member can perform a PUT.
E. A user whose role is Member can perform a POST.
F. A user whose role is Member can perform a GET.
Answer: ABCE
9.For
purposes,
you need to record how many times a given JSP is invoked before the user's session has been created.
The JSP's destroy method
stores
this information to a database.
Which JSP code snippet
keeps
track of this count for the lifetime of the JSP page?
A. <%! int count = 0; %>
<% if ( request.getSession(false) == null ) count++; %>
B. <%@ int count = 0; %>
<% if ( request.getSession(false) == null ) count++; %>
C. <% int count = 0;
if ( request.getSession(false) == null ) count++; %>
D. <%@ int count = 0;
if ( request.getSession(false) == null ) count++; %>
E. <%! int count = 0;
if ( request.getSession(false) == null ) count++; %>
Answer:A
10.You have built a collection of custom tags for your web application. The TLD file is located in the file:
/WEBINF/
myTags.xml. You refer to these tags in your JSPs using the symbolic name: myTags.
Which deployment descriptor element must you use to make this link between the symbolic name and the
TLD file name?
A. <taglib>
<name>myTags</name>
<location>/WEBINF/
myTags.xml</location>
</taglib>
B. <tags>
<name>myTags</name>
<location>/WEBINF/
myTags.xml</location>
</tags>
C. <tags>
<tagsuri>
myTags</tagliburi>
<tagslocation>/
WEBINF/
myTags.xml</tagslocation>
</tags>
D. <taglib>
<tagliburi>
myTags</tagliburi>
<tagliblocation>/
WEBINF/
myTags.xml</tagliblocation>
</taglib>
Answer:D
11.1: package com:example;
2: import java:util:*;
3: public class Appliance {
4: private Map props;
5: public Appliance() {
6: this:props = new HashMap getProperties() {
10: return this:props;
11: }
12: private void initialize() {
13: // code to load appliance properties
14: }
15: }
Click the Exhibit button .
The Appliance class is a Singleton that loads a set of properties into a Map from an external data source.
Assume:
? An instance of the Appliance class exists in the applicationscoped
attribute, appl
? The appliance object
includes
the name property that
maps to the value Cobia
? The requestscoped
attribute, prop, has the value name.
Which two EL code snippets will display the string Cobia? (Choose two.)
A. ${appl.properties.name}
B. ${appl.properties.prop}
C. ${appl.properties[prop]}
D. ${appl.properties[name]}
E. ${appl.getProperties().get(prop)}
F. ${appl.getProperties().get('name')}
Answer:AC
12.1: package com:example;
2:
3: public class Product {
4: private String name;
5: private double price;
6:
7: public Product() {
8: this( "Default", 0:0 );
9: }
10:
11: public Product( String name, double price ) {
12: this:name = name;
13: this:price = price;
14: }
15:
16: public String getName() {
17: return name;
18: }
19:
20: public void setName(String name) {
21: this:name = name;
22: }
23:
24: public double getPrice() {
25: return price;
26: }
27:
28: public void setPrice(double price) {
29: this:price = price;
30: }
31: }
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:BDE
13.Assume that a news tag library contains the tags lookup and item:
lookup Retrieves the latest news headlines and executes the tag body
once for each headline. Exposes a NESTED pagescoped
attribute called headline of type com.example.Headline
containing details for that headline.
item Outputs the HTML for a single news headline. Accepts an
attribute info of type com.example.Headline containing
details for the headline to be rendered.Which snippet of JSP
code returns the latest news headlines in an HTML table, one
per row?
A. <table>
<tr>
<td>
<news:lookup />
<news:item info="${headline}" />
</td>
</tr>
</table>
B. <news:lookup />
<table>
<tr>
<td><news:item info="${headline}" /></td>
</tr>
</table>
C. <table>
<news:lookup>
<tr>
<td><news:item info="${headline}" /></td>
</tr>
</news:lookup>
</table>
D. <table>
<tr>
<news:lookup>
<td><news:item info="${headline}" /></td>
</news:lookup>
</tr>
</table>
Answer:C
14.You are creating a web form with this HTML:
11: <form action="sendOrder.jsp">
12: <input type="text" name="creditCard">
13: <input type="text" name="expirationDate">
14: <input type="submit">
15: </form>
Which HTTP method is used when sending this request from the browser?
A. GET
B. PUT
C. POST
D. SEND
E. FORM
Answer: A
15.Your web application requires the ability to load and remove web files dynamically to the web
container's file system.
Which two HTTP methods are used to perform these actions? (Choose two.)
A. PUT
B. POST
C. SEND
D. DELETE
E. REMOVE
F. DESTROY
Answer:AD
16.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 LastModified
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