Which two create an instance of com.example.Product and initialize the name and price properties to the name and price request parameters?

View the Exhibit.

Assume the product attribute does NOT yet exist in any scope.
Which two create an instance of com.example.Product and initialize the name and price properties
to the name and price request parameters? (Choose two)

View the Exhibit.

Assume the product attribute does NOT yet exist in any scope.
Which two create an instance of com.example.Product and initialize the name and price properties
to the name and price request parameters? (Choose two)

A.
<jsp:useBean id=”product” class=”com.example.Product” />
<jsp:setProperty name=”product” property=”*” />

B.
<jsp:useBean id=”product” class=”com.example.Product” />
<% product.setName( request.getParameter( “name” ) ); %>
<% product.setPrice( request.getParameter( “price” ) ); %>

C.
<jsp:useBean id=”product” class=”com.example.Product” />
<jsp:setProperty name=”product” property=”name”
value=”${param.name}” />
<jsp:setProperty name=”product” property=”price”
value=”${param.price}” />

D.
<jsp:useBean id=”product” class=”com.example.Product”>
<jsp:setProperty name=”product” property=”name”
value=”${name}” />
<jsp:setProperty name=”product” property=”price”
value=”${price}” />
</jsp:useBean>



Leave a Reply 4

Your email address will not be published. Required fields are marked *


giuseppe

giuseppe

A, C ok BUT why not B?

giuseppe

giuseppe

Maybe because scritping is not best practice

ye

ye

because setPrice method require a double parameter?

Zaid

Zaid

You are right, The conversion from string to double is not supported when using scripting.
Ref : “Head First Servlets & JSP” page 362