It's not a secret anymore!
The moose likes Struts and the fly likes getting the value from <bean:write> tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "getting the value from <bean:write> tag" Watch "getting the value from <bean:write> tag" New topic

getting the value from <bean:write> tag

Krish Yeruva
Ranch Hand

Joined: Sep 17, 2008
Posts: 58
Can I do like this in JSP:
String str = "<bean:write name="XXX" property='XXX">"
Can you people suggest me, how can I get the value into String from <bean:write> ?

Thanks in advance

Thanks & Regards
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46383
I think this would sit better on our JSP forum: Moving thread.
Krish Yeruva
Ranch Hand

Joined: Sep 17, 2008
Posts: 58
Can anyone give me the response for the above query?
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
Writing scriptlet code is discouraged. You shouldn't need to have to use a scriptlet string variable.

If you must though, here are a couple of approaches
1 - use EL rather than scriptlet code. ie the value is ${}

2 - realise that the bean is an attribute in scope, get a hold of the bean in a scriptlet variable (with a <jsp:useBean> tag) and then call the get method directly.

3 - Use JSTL to store the string value as another page attribute

Khalil Salman

Joined: Sep 05, 2010
Posts: 11
I solve that issue by using <html:hidden> tag:

if it is:
<bean:write name="XXX" property='YYY">

then I put:
<html:hidden name="XXX" property="YYY"/>
next to it...
Raghava Chary

Joined: May 06, 2011
Posts: 6
<bean:define id="temp" name="formname" property="propertyname" type="java.lang.String"/>
<%String tmp=temp;%>
I agree. Here's the link:
subject: getting the value from <bean:write> tag
It's not a secret anymore!