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

After a merger with another small business, your company has inherited a legacy WAR file but the

original source files were lost. After reading the documentation of that web application, you

discover that the WAR file contains a useful tag library that you want to reuse in your own webapp

packaged as a WAR file.

What do you need to do to reuse this tag library?


Options are :

  • Unpack the legacy WAR file, move the TLD file to the META-INF directory, move the class files to the top-level directory, repackage the WAR, and place that WAR file in your webapp's WEB-INF directory.
  • Unpack the legacy WAR file, move the TLD file to the META-INF directory, repackage the whole thing as a JAR file, and place that JAR file in your webapp's library directory.
  • Unpack the legacy WAR file, move the TLD file to the META-INF directory, move the class files to the top-level directory, repackage the whole thing as a JAR file, and place that JAR file in your webapp's library directory.
  • Simply rename the legacy WAR file as a JAR file and place it in your webapp's library directory.

Answer : Unpack the legacy WAR file, move the TLD file to the META-INF directory, move the class files to the top-level directory, repackage the whole thing as a JAR file, and place that JAR file in your webapp's library directory.

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

Given:

1. <% int[] nums = {42,420,4200};

2. request.setAttribute("foo", nums); %>

3. ${5 + 3 lt 6}

4. ${requestScope['foo'][0] ne 10 div 0}

5. ${10 div 0}

What is the result?


Options are :

  • true true Infinity
  • false true Infinity
  • Compilation or translation fails.
  • true true
  • false true 0
  • false true
  • false true Infinity

Answer : false true Infinity

A custom JSP tag must be able to support an arbitrary number of attributes whose names are

unknown when the tag class is designed. Which two are true? (Choose two.)

A. The <body-content> element in the echo tag TLD must have the value JSP.

B. The echo tag handler must define the setAttribute(String key, String value) method.

C. The <dynamic-attributes>true</dynamic-attributes> element must appear in the echo tag TLD.

D. The class implementing the echo tag handler must implement the

javax.servlet.jsp.tagext.IterationTag interface.

E. The class implementing the echo tag handler must implement the

javax.servlet.jsp.tagext.DynamicAttributes interface.


Options are :

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

Answer : C,E

Which two JSTL URL-related tags perform URL rewriting? (Choose two.)

A. url

B. link

C. param

D. import

E. redirect


Options are :

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

Answer : A,E

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

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.


Options are :

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

Answer : A,B,F

Given the JSP code:

10. <html>

11. <body>

12. <jsp:useBean id='customer' class='com.example.Customer' />

13. Hello, ${customer.title} ${customer.lastName}, welcome

14. to Squeaky Beans, Inc.

15. </body>

16. </html>

Which three types of JSP code are used? (Choose three.)

A. Java code

B. template text

C. scripting code

D. standard action

E. expression language


Options are :

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

Answer : B,D,E

Which three web application deployment descriptor elements allow web components to gain

references to resources or EJB components? (Choose three.)

A. ejb-ref

B. jdbc-ref

C. servlet-ref

D. resource-ref

E. javamail-ref

F. ejb-remote-ref

G. resource-env-ref


Options are :

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

Answer : A,D,G

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

Given the JSP code:

<% request.setAttribute("foo", "bar"); %>

and the Classic tag handler code:

5. public int doStartTag() throws JspException {

6. // insert code here

7. // return int

8. }

Assume there are no other "foo" attributes in the web application.

Which invocation on the pageContext object, inserted at line 6, assigns "bar" to the variable x?


Options are :

  • String x = (String) pageContext.getRequest().getAttribute("foo");
  • It is NOT possible to access the pageContext object from within doStartTag
  • String x = (String) pageContext.getAttribute("foo");
  • String x = (String) pageContext.getRequestScope("foo");
  • String x = (String) pageContext.getAttribute("foo", PageContext.ANY_SCOPE);

Answer : String x = (String) pageContext.getRequest().getAttribute("foo");

Which three are true about TLD files? (Choose three.)

A. The web container recognizes TLD files placed in any subdirectory of WEB-INF.

B. When deployed inside a JAR file, TLD files must be in the META-INF directory, or a

subdirectory of it.

C. A tag handler's attribute must be included in the TLD file only if the attribute can accept

request-time expressions.

D. The web container can generate an implicit TLD file for a tag library comprised of both simple

tag handlers and tag files.

E. The web container can automatically extend the tag library map described in a web.xml file by

including entries extracted from the web application's TLD files.


Options are :

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

Answer : A,B,E

Given the definition of MyServlet:

11. public class MyServlet extends HttpServlet {

12. public void service(HttpServletRequest request,

13. HttpServletResponse response)

14. throws ServletException, IOException {

15. HttpSession session = request.getSession();

16 session.setAttribute("myAttribute","myAttributeValue");

17. session.invalidate();

18. response.getWriter().println("value=" +

19. session.getAttribute("myAttribute"));

20. }

21. }

What is the result when a request is sent to MyServlet?


Options are :

  • The string "value=null" appears in the response stream
  • The string "value=myAttributeValue" appears in the response stream
  • An InvalidSessionException is thrown at runtime.
  • An IllegalStateException is thrown at runtime.

Answer : An IllegalStateException is thrown at runtime.

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

To take advantage of the capabilities of modern browsers that use web standards, such as

XHTML and CSS, your web application is being converted from simple JSP pages to JSP

Document format. However, one of your JSPs, /scripts/screenFunctions.jsp, generates a

JavaScript file. This file is included in several web forms to create screen-specific validation

functions and are included in these pages with the following statement:

10. <head>

11. <script src='/scripts/screenFunctions.jsp'

12. language='javascript'

13. type='application/javascript'> </script>

14. </head>

15. <!-- body of the web form -->

Which JSP code snippet declares that this JSP Document is a JavaScript file?


Options are :

  • None of the Above
  • No declaration is needed because the web form XHTML page already declares the MIME type of the /scripts/screenFunctions.jsp file in the