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

How to use java bean property (instance) in jsp (jstl tag) if test condition  RSS feed

 
sneha laskar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a java bean class with a getter method returning a string for the property logR;

In my JSP I want to access this property in an if test condition :

<jsp:useBean id="beanobj" class="MyBean"></jsp:useBean>
<c:if test="${beanobj.logR == 'success'}">
<c:redirect url="MyJSP.jsp"></c:redirect>
</c:if>

However, it shows an error :
"ERROR READING logR from class MyBean"

May I know what am I supposed to alter in my code???

- SnehaJay

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you should show us your bean code, please UseCodeTags.
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two suggestions

1 - Put the MyBean class in a package, and reference the class by its full package name in the useBean tag
ie <jsp:useBean id="beanobj" class="com.mypackage.MyBean"></jsp:useBean>

JSPs have trouble referencing beans that are in the 'default' package.

2 - ensure that your getter meets the javabeans standards
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!