Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in jsp bean

 
sundar sankar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Iam unable to setProperty for the method Hm(String st,Stirng st) pl help me the code is:
import java.util.*;
public classs beanclass
{
private HashMap hm=new HashMap();
public void setHm(Stirng st,String st1)
{
hm.put(st,st1);
}
public Map getHm()
{
return hm;
}
}
The jsp code is:
<html>
<body>
<jsp:useBean id="be" class = beanclass/>
<jsp:setProperty name="be" property=("first", "secon")/>
</body>
</html>
Thanks in advance
sankar
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Where did you get that notation from ? Look in the spec about the setProperty action, and especially on how to use the "property" attribute. You'll discover several misconceptions.
 
sundar sankar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christophe Verre,
Thanks i will look the jsp.I got this notation <jsp:setProperty name="be" property=("first", "secon")/> from my imagination with to add a value to hashMap.

Thanks
sankar
 
satya gopal
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi


i think in order to create the bean and set the properties there should be no argument constuctor in the class.


if i am wrong please help me
 
sundar sankar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi satya gopal,
Yes, bean class should have either default cnstructor (or) no-arg contructor.
 
sundar sankar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christophe Verre ,
I read jsp spec releted to java Bean ,i think there is no way so add/put a key and value in Map.I need ranchers advice in this regard.
Thanks in advance
sankar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic