• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:useBean Difficulty

 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please tell me...weather...

these two things VALID,SAME and CORRECT

1 :
<jsp:useBean id="product" class="foo.person" scope="request">

<jsp:setProperty name="product" property="name" param="id1"/>

<jsp:setProperty name="product" property="name" param="id2"/>

</jsp:useBean>


2:
<jsp:useBean id="product" class="foo.person" scope="request">

<jsp:setProperty name="product" property="name" value="<%=request.getParameter("id1")%>"/>

<jsp:setProperty name="product" property="name" value="<%=request.getParameter("id2")%>"/>

</jsp:useBean>



Thank you...
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both are same, In first case,

param="id1", sets the request object parameter named "id1" to bean property..

In second case,

value="<%=request.getParameter("id1")%>", you are setting it explicitly.

Follow this link, to get clear idea about <jsp:setProperty..
 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Sagar..
 
Sandeep Bhandari
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference is that the value supplied in second argument will not be converted from String to integer type but in first case, if required it will be done without you knowing about it.

I would say both are VALID and CORRECT but not SAME.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please tell me...weather...

It's shiny
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic