Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

"out"ing values stored in javabean  RSS feed

 
Aaron Parker
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I get a value (or call the get method) from a javabean to display on my jsp page?

I've got my usebean statement, but if I have a getEmail method in my bean, how do I get the value of the email to the jsp page?

I've tried




There is a getEmail() and an variable email in the bean.

Thanks.
[ March 24, 2005: Message edited by: Aaron Parker ]
 
anupa oru
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You have to the following
<jsp:useBean id="subscriberBean" class="java169.project1.Subscriber" scope="session" />
<jsp:getProperty name="subscriberBean" property="email">//this get the email property and it will be printed out.
</jsp:useBean>
I hope this will work
Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by anupa oru:
Hi,
You have to the following
<jsp:useBean id="subscriberBean" class="java169.project1.Subscriber" scope="session" />
<jsp:getProperty name="subscriberBean" property="email">//this get the email property and it will be printed out.
</jsp:useBean>
I hope this will work
Thanks



Putting the getProperty tag in the body of the useBean tag will cause it to be called only when the JSP page first creates the bean.
It should be:


 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can still use the <cut> tag to display the property. In your example, though, you used the wrong name. You have to use the name from the "id" attribute of the jsp:useBean tag.

If you use the following tag, it should work.

<cut value="${subscriberBean.email}" />
[ March 24, 2005: Message edited by: Merrill Higginson ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prefer <cut> to <jsp:getProperty>.

P.S. Ben has an error in his example. The second tag should be getProperty.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.P.S.

By the way: what is the purpose of the useBean tag to begin with? If you are using it to create the bean and store it in the session, that's fine. But be advised that if the bean is already in the session, and you are going to be using the JSTL <cut> tag to access it, the useBean tag is completely superfluous.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!