0

How do I convert a Struts2 variable into a regular JSP <% variable?

<s:iterator var="item" value="results">
   <jsp:useBean id="item" type="com.google.appengine.api.search.ScoredDocument"/>

Caused by: java.lang.InstantiationException: bean item not found within scope
Chloe
  • 25,162
  • 40
  • 190
  • 357

1 Answers1

0

This worked: <s:set var="item" value="%{item}"/>

<s:iterator var="item" value="results">
    <s:set var="item" value="%{item}"/>
    <jsp:useBean id="item" type="com.google.appengine.api.search.ScoredDocument" />
    <%= item %><br/>
Chloe
  • 25,162
  • 40
  • 190
  • 357
  • Why do you want to do that ? Just use Struts Tags, and avoid scriptlets – Andrea Ligios Oct 31 '13 at 09:36
  • @AndreaLigios Because it is such a hassle to deal with Struts tags. They do not perform as expected. They do not follow the principal of least surprise. At least with scriptlets, you have full Java control and can explicitly determine what is going on. In this case, I wanted to print a deeply nested double as an integer. – Chloe Oct 31 '13 at 14:20
  • Just use the SIMPLE theme, no suprises with that ;) Unluckily, the XHTML (that generates HTML for you) is the default Struts2 theme... Just change it in `struts.xml`, and Struts Tags will be generated without unwanted code ;) Example: http://stackoverflow.com/a/4561245/1654265 – Andrea Ligios Oct 31 '13 at 14:35