This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 36453
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: 1016
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
Similar Threads
passing object from JSTL into applet
query string in html:link
how to iterate a arraylist and print values in table using logic:iterate
help :how to get value from logic:iterate
Java Script not working in firefox but working in IE