• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts tags and JSTL

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to use the JSTL expressons along with Struts tags? On a JSP page, I have a bean defined which contains a map of lists (with a Dynaform). I am able to successfully access the bean for non-struts items like the following:
<select name='sites' id='sites' >
<c:forEach items='${myBean.lists.sites}' var='siteName'>
<option value="<c:out value='${siteName}'/>"> <c:out value="${siteName}"/> </option>
</c:forEach>
</select>

However, when I try the following, I get an error:
<html:select property='sites'>
<html:options collection="${myBean.lists.sites}"/>
</html:select>
with the error stating:
Cannot find bean under name org.apache.struts.taglib.html.BEAN

Since the non-struts select works, I am wondering if something else is required to get Struts working with the JSTL expression language. I have also tried changing the options to the following:
<html:options collection="<c:out value='${myBean.lists.sites}'/>"/>
Thank you.
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi James,
There is a problem with nesting the jstl tags within the struts tags. Independently you can use them on a jsp page and it would not cause a problem but if you try to nest a jstl tag within a struts tag, the page would break. The reason is very historical, since jstl was written over struts tags, the jstl tags support them while as struts tags have no knowledge of the jstl syntax.
Sahil
 
James Falek
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the insight - unfortunate as it might be ;-(
Thanks again,
James
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, There is an extension to the struts-tags called struts-el, which allows you to resolve jstl expressions inside struts tags. It is in the contrib directory of your struts distribution.
it will allow you to do things like
<html-el:options collection="${myBean.lists.sites}"/>
[ December 17, 2003: Message edited by: Andre Mermegas ]
 
Author
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used Struts EL tag lib on my last project. It is much more productive. You end up doing a lot less bean efine or c:set tags.
Once you use Struts EL, you will not go back to using regular Struts tags.
reply
    Bookmark Topic Watch Topic
  • New Topic