Which code snippet, in submit.jsp, instantiates an instance of com.example.Product that contains the results of the form submission?

Click the Exhibit button.

Given the HTML form:
1. <html>
2. <body>
3. <form action=”submit.jsp”>
4. Name: <input type=”text” name=”i1″><br>
5. Price: <input type=”text” name=”i2″><br>
6. <input type=”submit”>
7. </form>
8. </body>
9. </html>
Assume the product attribute does NOT yet exist in any scope.
Which code snippet, in submit.jsp, instantiates an instance of com.example.Product that contains
the results of the form submission?

Click the Exhibit button.

Given the HTML form:
1. <html>
2. <body>
3. <form action=”submit.jsp”>
4. Name: <input type=”text” name=”i1″><br>
5. Price: <input type=”text” name=”i2″><br>
6. <input type=”submit”>
7. </form>
8. </body>
9. </html>
Assume the product attribute does NOT yet exist in any scope.
Which code snippet, in submit.jsp, instantiates an instance of com.example.Product that contains
the results of the form submission?

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

B.
<jsp:useBean id=”product” class=”com.example.Product” />
${product.name = param.i1}
${product.price = param.i2}

C.
<jsp:useBean id=”product” class=”com.example.Product”>
<jsp:setProperty name=”product” property=”name”
param=”i1″ />
<jsp:setProperty name=”product” property=”price”
param=”i2″ />
</jsp:useBean>

D.
<jsp:useBean id=”product” type=”com.example.Product”>
<jsp:setProperty name=”product” property=”name”
value=”<%= request.getParameter( “i1″ ) %>” />
<jsp:setProperty name=”product” property=”price”
value=”<%= request.getParameter( “i2″ ) %>” />
</jsp:useBean>



Leave a Reply 4

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


Allan Santos

Allan Santos

C indeed

Jeena

Jeena

C is correct but Why is D wrong. Its not the recommended way but still it is not incorrect.

me

me

type:It is mainly used with class or beanName attribute. If you use it without class or beanName, no bean is instantiated.

class: instantiates the specified bean class (i.e. creates an object of the bean class) but it must have no-arg or no constructor and must not be abstract.