Search your topic in Java2share
Home > SCWCD > SCWCD Question Bank
eXTReMe Tracker


8. Building JSP Pages Using Standard Actions (SCWCD)

Objective

  • Given a design goal, create a code snippet using the following standard actions: jsp:useBean (with attributes: 'id', 'scope', 'type', and 'class'), jsp:getProperty, jsp:setProperty (with all attribute combinations), and jsp:attribute.
  • Given a design goal, create a code snippet using the following standard actions: jsp:include, jsp:forward, and jsp:param

 

Q1. 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

Answer: B, D, E

Q2. Which JSP standard action can be used to import content from a resource called foo.jsp?

A. <jsp:import file='foo.jsp' />
B. <jsp:import page='foo.jsp' />
C. <jsp:include page='foo.jsp' />
D. <jsp:include file='foo.jsp' />
E. <jsp:import>foo.jsp</jsp:import>
F. <jsp:include>foo.jsp</jsp:include>

Answer: C

Q3. Click the Task button.
A servlet context listener loads a list of com.example.Product objects from a database and stores that list into the catalog attribute of the ServletContext object.Place code snippets to construct a jsp:useBean standard action to access this catalog.


Answer:
id=’catalog’
type=’java.util.List’
scope=’application’

Q4. A session-scoped attribute is stored by a servlet, and then that servlet
forwards to a JSP page. Which three jsp:useBean attributes must be used to access this attribute in the JSP page? (Choose three.)

A. id                                                                 B. name
C. bean                                                            D. type
E. scope                                                           F. beanName

Answer: A, D, E