well, actually, the Vector is in the session. When I use
instead of
it does work..
isuraeru
Greenhorn
Joined: Jan 28, 2003
Posts: 7
posted
0
Originally posted by Erik Pragt: well, actually, the Vector is in the session. When I use
instead of
it does work..
You can use:
Mark Howard
Ranch Hand
Joined: Feb 14, 2001
Posts: 285
posted
0
Hi Erik Yup, first declare the bean using <jsp:useBean> before using the <jsp:getProperty> and <jsp:setProperty> functions.
Maulin Vasavada
Ranch Hand
Joined: Nov 04, 2001
Posts: 1863
posted
0
hi Erik consider these two points, 1. in the first post you provided, you have object "items" in the session which is Vector and not a bean. 2. when you do getProperty then it looks for a bean in page, request, session, application scopes (well this sequence of lookup would be altogether another discussion i would say) and tries to do getAttribute("beanname") from them. if it does find it then tries to get the property you specified.
given these two points, we can easily see that when you tried to do getProperty on the "item" bean it looked for that in page,request,sesssion,application scopes where it didn't find it as you have a Vector of "items" in the session (not the bean), right? doesn't matter that you did use the for loop. it doesn't change the fact that we don't have the appropriate bean object in the session. so that approach obviously doesnt work. as you have Vector of Beans in the session and you want to use each of those bean object separately to getProperty, it won't help you to use useBean tag either...how will it help?? the only way is to ignore use of getProperty tag and use
item.getPrice();
that you suggested in your second post....that is the only way you would get this working.... you can't put objects of beans with the same name in the session.... hope this helps. regards maulin.
Hi Erik, Is it possible you spelled the word "property" wrong in your code as you did in your sample?
<jsp:getProperty name="item" propery="price" />
<a href="http://www.getlocaldeals.com" target="_blank" rel="nofollow">Free local coupons</a>
Erik Pragt
Ranch Hand
Joined: Sep 08, 2001
Posts: 125
posted
0
Hello everyone, sorry about the typos, the most useful answer came from Maulin. I figured that it wouldn't be possible to do it the way I wanted to do it, but you clearly explained why I was wrong. My thanks for that, you were a big help. Everyone else: thanks for your response, I also really appriciate that! Greetings, Erik