Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting the value from <bean:write> tag

 
Krish Yeruva
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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



 
Campbell Ritchie
Sheriff
Posts: 48386
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this would sit better on our JSP forum: Moving thread.
 
Krish Yeruva
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone give me the response for the above query?
 
Stefan Evans
Bartender
Pie
Posts: 1670
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ${XXX.xxx}

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
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<bean:define id="temp" name="formname" property="propertyname" type="java.lang.String"/>
<%String tmp=temp;%>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic