• Post Reply Bookmark Topic Watch Topic
  • New Topic

SCWCD question confuse

 
Tony Tung
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>

Answer: A, C

why B option is wrong ?

I can not see any question in option B .

Someone can tell what wrong with it , thanks a lot .
 
sukanya mohan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can someone elaborate on this?
 
Ankit Garg
Sheriff
Posts: 9597
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony please Quote Your Sources when you post a question...
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<jsp:useBean id="product" class="com.example.Product" />
<% product.setName( request.getParameter( "name" ) ); %>
<% product.setPrice( request.getParameter( "price" ) ); %>

From which place did you get product object? The invocations are good but the product object does not exist in your code.
You should do something like this:



Correct me if I am wrong.
 
Tony Tung
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry , I am too lazy to test code .

B option wrong point at

<% product.setPrice( request.getParameter( "price" ) ); %>

it should be <% product.setPrice( Double.ParseDouble(request.getParameter( "price" )) ); %>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65682
129
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Tongxx wrote:sorry , I am too lazy to test code .


You cannot be serious!

And yet you expect people to take their time to help you!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65682
129
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Tony Tongxx", please check your private messages for an important administrative matter.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!