aspose file tools*
The moose likes JSP and the fly likes using JSTL in struts framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "using JSTL in struts framework" Watch "using JSTL in struts framework" New topic
Author

using JSTL in struts framework

Nishad Banodkar
Greenhorn

Joined: Jun 08, 2011
Posts: 5
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

Joined: Jan 10, 2002
Posts: 61421
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61421
    
  67

Also, it should be items="${modelHelperResult}">
Nishad Banodkar
Greenhorn

Joined: Jun 08, 2011
Posts: 5
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

Joined: Jun 08, 2011
Posts: 5
oops....i meant
<c:forEach var="modelHelperList" items="${modelHelperResult}">

(printing mistake for $ in previous post)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61421
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using JSTL in struts framework