310-083 Sun Certified Web Component Developer for J2EE 5 Set 8

 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?


Options are :

Answer :

Which two statements are true about the security-related tags in a valid Java EE deployment

descriptor? (Choose two.)

A. Every <security-constraint> tag must have at least one <http-method> tag.

B. A <security-constraint> tag can have many <web-resource-collection> tags.

C. A given <auth-constraint> tag can apply to only one <web-resource-collection> tag.

D. A given <web-resource-collection> tag can contain from zero to many <url-pattern> tags.

E. It is possible to construct a valid <security-constraint> tag such that, for a given resource, no

user roles can access that resource.


Options are :

  • B,E
  • A,E
  • C,E
  • D,E

Answer : B,E

You need to store a Java long primitive attribute, called customerOID, into the session scope.

Which two code snippets allow you to insert this value into the session? (Choose two.)

A. long customerOID = 47L;

session.setAttribute("customerOID", new Long(customerOID));

B. long customerOID = 47L;

session.setLongAttribute("customerOID", new Long(customerOID));

C. long customerOID = 47L;

session.setAttribute("customerOID", customerOID);

D. long customerOID = 47L;

session.setNumericAttribute("customerOID", new Long(customerOID));

E. long customerOID = 47L;

session.setLongAttribute("customerOID", customerOID);

F. long customerOID = 47L;

session.setNumericAttribute("customerOID", customerOID);


Options are :

  • A,F
  • A,C
  • A,E
  • A,D

Answer : A,C

310-090 Sun Certified Business Component Developer for J2EE Set 1

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?


Options are :

  • 10. Cookie c = new Cookie("creditCard", usersCard); 11. c.setSecure(true); 12. c.setAge(10368000); 13. response.addCookie(c);
  • 10. Cookie c = new Cookie("creditCard", usersCard); 11. c.setHttps(true); 12. c.setMaxAge(10368000); 13. response.setCookie(c);
  • 10. Cookie c = new Cookie("creditCard", usersCard); 11. c.setSecure(true); 12. c.setMaxAge(10368000); 13. response.addCookie(c);
  • 10. Cookie c = new Cookie("creditCard", usersCard); 11. c.setSecure(true); 12. c.setAge(10368000); 13. response.setCookie(c);
  • 10. Cookie c = new Cookie("creditCard", usersCard); 11. c.setHttps(true); Sun 310-083 Exam BrainDumps.com 153 12. c.setAge(10368000); 13. response.addCookie(c);

Answer : 10. Cookie c = new Cookie("creditCard", usersCard); 11. c.setSecure(true); 12. c.setMaxAge(10368000); 13. response.addCookie(c);

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, user-oriented 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 page-scoped 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?


Options are :

  • public void doTag() throw JspException { try { for ( Enum value : getEnumValues() ) { getJspContext().setAttribute("enumValue", value); getJspBody().invoke(getJspContext().getWriter()); } } (Exception e) { throw new JspException(e); } }
  • public void doTag() throw JspException { try { for ( Enum value : getEnumValues() ) { pageContext.setAttribute("enumValue", value); getJspBody().invoke(getOut()); } } (Exception e) { throw new JspException(e); } }
  • public void doTag() throw JspException { try { for ( Enum value : getEnumValues() ) { getJspContext().setAttribute("enumValue", value); getJspBody().invoke(null); } } (Exception e) { throw new JspException(e); } }
  • 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 : public void doTag() throw JspException { try { for ( Enum value : getEnumValues() ) { getJspContext().setAttribute("enumValue", value); getJspBody().invoke(null); } } (Exception e) { throw new JspException(e); } }

Which retrieves all cookies sent in a given HttpServletRequest request?


Options are :

  • request.getCookies()
  • request.getAttributes()
  • request.getSession().getAttributes()
  • request.getSession().getCookies()

Answer : request.getCookies()

310-090 Sun Certified Business Component Developer for J2EE Set 10

Which method must be used to encode a URL passed as an argument to

HttpServletResponse.sendRedirect when using URL rewriting for session tracking?


Options are :

  • ServletResponse.encodeRedirectURL
  • HttpServletResponse.encodeRedirectURL
  • ServletResponse.encodeURL
  • HttpServletResponse.encodeURL

Answer : HttpServletResponse.encodeRedirectURL

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?


Options are :

  • TRACE
  • SEND
  • HEAD
  • GET
  • OPTIONS
  • ASK

Answer : HEAD

Which ensures that a JSP response is of type "text/plain"?


Options are :

  • <%@ page pageEncoding="text/plain" %>
  • <% response.setMimeType("text/plain"); %>
  • <%@ page contentType="text/plain" %>
  • <% response.setEncoding("text/plain"); %>
  • <%@ page contentEncoding="text/plain" %>
  • <%@ page mimeType="text/plain" %>

Answer : <%@ page contentType="text/plain" %>

310-090 Sun Certified Business Component Developer for J2EE Set 11

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}


Options are :

  • D,F
  • B,F
  • C,F
  • A,F

Answer : B,F

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>[email protected]</param-value>

45. </context-param>

Which JSP code snippet creates this email link?


Options are :

Answer : contact us

Which element of a web application deployment descriptor <security-constraint> element is

required?


Options are :

Answer :

310-090 Sun Certified Business Component Developer for J2EE Set 12

You need to store a floating point number, called Tsquare, in the session scope. Which two code

snippets allow you to retrieve this value? (Choose two.)

A. float Tsquare = session.getFloatAttribute("Tsquare");

B. float Tsquare = (Float) session.getAttribute("Tsquare");

C. float Tsquare = (float) session.getNumericAttribute("Tsquare");

D. float Tsquare = ((Float) session.getAttribute.("Tsquare")).floatValue();

E. float Tsquare = ((Float) session.getFloatAttribute.("Tsquare")).floatValue;

F. float Tsquare = ((Float) session.getNumericAttribute.("Tsquare")).floatValue;


Options are :

  • B,D
  • C,D
  • D,E
  • A,D

Answer : B,D

Which interface must a session attribute implement if it needs to be notified when a web container

persists a session?


Options are :

  • javax.servlet.http.HttpSessionActivationListener
  • javax.servlet.http.HttpSessionListener
  • javax.servlet.http.HttpSessionBindingListener
  • javax.servlet.http.HttpSessionAttributeListener

Answer : javax.servlet.http.HttpSessionActivationListener

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.


Options are :

  • A,C
  • A,E
  • A,B
  • A,D

Answer : A,C

310-090 Sun Certified Business Component Developer for J2EE Set 2

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);

}


Options are :

  • A,E
  • D,E
  • C,E
  • B,E

Answer : C,E

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>

Sun 310-083 Exam

BrainDumps.com 156

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?


Options are :

  • ${hobbies[paramValues.hobbyEnum[N]]}
  • ${hobbies.get(paramValues.hobbyEnum[N])}
  • ${hobbies[paramValues.hobbyEnum.get(N)]}
  • ${hobbies[hobbyEnum[N]}
  • ${hobbies[[email protected]'hobbyEnum'@N]}

Answer : ${hobbies[paramValues.hobbyEnum[N]]}

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}


Options are :

  • B,E
  • D,E
  • A,E
  • C,E

Answer : D,E

310-090 Sun Certified Business Component Developer for J2EE Set 3

A web application uses the HttpSession mechanism to determine if a user is "logged in." When a

user supplies a valid user name and password, an HttpSession is created for that user.

The user has access to the application for only 15 minutes after logging in. The code must

determine how long the user has been logged in, and if this time is greater than 15 minutes, must

destroy the HttpSession.

Which method in HttpSession is used to accomplish this?


Options are :

  • invalidateAfter
  • getCreationTime
  • getLastAccessedTime
  • getMaxInactiveInterval

Answer : getCreationTime

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);

Sun 310-083 Exam

BrainDumps.com 155

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);


Options are :

  • B,F
  • D,F
  • A,F
  • C,F

Answer : B,F

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.


Options are :

  • B,E
  • A,E
  • D,E
  • C,E

Answer : B,E

310-090 Sun Certified Business Component Developer for J2EE Set 4

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.


Options are :

  • C,E
  • A,E
  • B,E
  • D,E

Answer : B,E

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>


Options are :

  • A,G
  • A,F
  • A,C
  • A,B

Answer : A,G

Which is a benefit of precompiling a JSP page?


Options are :

  • It provides the ability to debug runtime errors in the application
  • It avoids execution of the _jspService method on the first request.
  • It avoids initialization on the first request
  • It provides better performance on the first request for the JSP page.

Answer : It provides better performance on the first request for the JSP page.

310-090 Sun Certified Business Component Developer for J2EE Set 5

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>


Options are :

  • B,E
  • D,E
  • C,E
  • A,E

Answer : B,E

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?


Options are :

  • <%-- this is a comment --%>
  • <% /** this is a comment **/ %>
  • <% // this is a comment %>

Answer :

What is true about Java EE authentication mechanisms?


Options are :

  • If you want your web application to support the widest possible array of browsers, and you want to perform authentication, the best choice of Java EE authentication mechanisms is DIGEST.
  • To use Java EE FORM authentication, you must declare two HTML files in your deployment descriptor, and you must use a predefined action in the HTML file that handles your user's login.
  • If your deployment descriptor correctly declares an authentication type of BASIC, the container automatically requests a user name and password whenever a user starts a new session.
  • If your deployment descriptor correctly declares an authentication type of CLIENT_CERT, your users must have a certificate from an official source before they can use your application.

Answer : To use Java EE FORM authentication, you must declare two HTML files in your deployment descriptor, and you must use a predefined action in the HTML file that handles your user's login.

310-090 Sun Certified Business Component Developer for J2EE Set 6

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?


Options are :

  • *.jsp true
  • *.jsp true
  • *.jsp true
  • *.jsp true
  • *.jsp

Answer : *.jsp true

In which three directories, relative to a web application's root, may a tag library descriptor file

reside when deployed directly into a web application? (Choose three.)

A. /WEB-INF

B. /META-INF

C. /WEB-INF/tlds

D. /META-INF/tlds

E. /WEB-INF/resources

F. /META-INF/resources


Options are :

  • A,B,D
  • A,B,C
  • A,C,D
  • A,C,E

Answer : A,C,E

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.


Options are :

  • A,B,E
  • A,B,F
  • A,B,C
  • A,B,D

Answer : A,B,C

310-090 Sun Certified Business Component Developer for J2EE Set 7

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions