aspose file tools*
The moose likes Struts and the fly likes <bean:write/> value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "<bean:write/> value" Watch "<bean:write/> value" New topic
Author

<bean:write/> value

Anutosh Swamy
Ranch Hand

Joined: Sep 20, 2007
Posts: 30

Can anyone help me with using the <bean:write/> value inside the scriptlet in JSP

Thanks in advance


K. Anutosh<br /> <br />SCJP 1.4<br />SCWCD 1.4<br />OCA (Paper I)
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

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


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Anutosh Swamy
Ranch Hand

Joined: Sep 20, 2007
Posts: 30

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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Sep 20, 2007
Posts: 30

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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <bean:write/> value
 
Similar Threads
passing parameters
Displaying an image in jsp using struts
Doubts about bean:write
set html option value by bean: message key=...
Iterate Hashmap through struts