Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using JSTL in struts framework

 
Nishad Banodkar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

m new to JSTL.
i have an action class which is setting one arraylist in request object, code goes like this
request.setAttribute("modelHelperResult",modelHelperResult);
modelHelperResult is an arrayList

now on jsp, i am retriving this arraylist to print its contents, it has all string objects in it.

now for the same purpose i want to use <c:forEach/>
being a new to the world of JSTL, whatever i could read regarding the tag, i coded like this:
<c:forEach var="modelHelperList" items="{modelHelperResult}">
${modelHelperList}
</c:forEach>


its not giving any result, instead its printing ${modelHelperList} as text.

plwase help me regarding the same....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure that your deployment descriptor is not using the Servlets 2.3 DTD. That will disable the EL.

See the JspFaq to make sure your web app is set up properly for the EL and JSTL.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, it should be items="${modelHelperResult}">
 
Nishad Banodkar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see,

when i do
<c:forEach var="modelHelperList" items="S{modelHelperResult}">
${modelHelperList}
</c:forEach>
(i.e. putting "$")
i get error as
attribute items does not accept any expressions

when i insert
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
in DD file
it fails in deployment.

can you please guide me all steps for using TLD???
 
Nishad Banodkar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops....i meant
<c:forEach var="modelHelperList" items="${modelHelperResult}">

(printing mistake for $ in previous post)
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds as if your web app is badly misconfigured.

Check the JspFaq. Make sure that your web.xml is properly declared using servlets 2.4 or 2.5 and not 2.3. And make sure you are using the appropriate version of the JSTL for your container.

If you have a bad mix of versions, you will get these types of errors.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic