Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<bean:write/> value

 
Anutosh Swamy
Ranch Hand
Posts: 30
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone help me with using the <bean:write/> value inside the scriptlet in JSP

Thanks in advance
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anutosh Swamy wrote:Can anyone help me with using the <bean:write/> value inside the scriptlet in JSP

Had you tried ? We would like to see some efforts from your side
 
Anutosh Swamy
Ranch Hand
Posts: 30
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For example :

what i need inside JSP is

<% System.out.println(<bean: write name="userList" property="userName"/> %>

that's all

but this is giving me this error - illegal start of expression
org.apache.jasper.JasperException: Unable to compile class for JSP

So what will be the possible solution for this.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anutosh Swamy wrote:
<% System.out.println(<bean: write name="userList" property="userName"/> %>

For this I will put some pointers,
1. bean:write uses beans "name", so you have a bean object. (Be careful about the scope)
2. On bean object, you know how to call its property method, like myBean.getProperty(); in scriptlet

HTH
 
Anutosh Swamy
Ranch Hand
Posts: 30
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me make it more specific

I have a list object set in the request as an attribute which contains all the details about the users of an application, in JSP am displaying the list of the users using <logic:present>, <logic:iterate> and <bean:write> this is working fine but the problem is there when I have to apply some if() condition, for this I have to make use of the <bean:write> value inside the scriptlet.

 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't get it. You can do whatever you want to do in scripltlet, whether its is if conditions or for loops. My previous post provides some hints on how to get the bean values in scriptlet. Its straightforward, accessing bean using tags OR using same bean "name" in scripltet is same (look for the resultant _jsp Java code), but later use is discouraged.
Anutosh Swamy wrote:..the problem is there when I have to apply some if() condition, for this I have to make use of the <bean:write> value inside the scriptlet.

You can have an JSTL's c:if tag OR you can use logic:equal tag.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic