• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JSTL Problem

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using tomcat 5.5 and jstl 1.1 (2.0). I am having a problem with the following code

<jsp:useBean id="values" type="java.util.List" scope="request"/>

<html>
<head>
<title> title goes here</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<table width="100%" border="0" class="fieldlabel">
<tr> Cruise lines </tr>

<c:forEach items="${values}" var="value" varStatus="status">
<c:if test="${status.first}"> first </c:if>
<c:if test="${status.last}"> last </c:if>
<tr><td>zz<c:out value="${value}" default="no value available"/></tr></td>
</c:forEach>

<c:forTokens items="a;b;c;d" delims=";" var="current">
<tr><td><c:out value="${current}"/></td></tr>
</c:forEach>

</body>
</html>


Nothing prints for c:forEach of c:forTokens

when I do a view source when the jsp is rendered in the browser I see the following:

<table width="100%" border="0" class="fieldlabel">
<tr> Cruise lines </tr>

<c:forEach items="[one, two, three]" var="value" varStatus="status">
<c:if test=""> first </c:if>
<c:if test=""> last </c:if>
<tr><td>zz<c:out value="" default="no value available"/></tr></td>
</c:forEach>

<c:forTokens items="a;b;c;d" delims=";" var="current">
<tr><td><c:out value=""/></td></tr>
</c:forEach>

</body>
</html>



I see the values in the items but they do not print. What stupid thing am i doing wrong?

Thanks
 
Vic Newman
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never mind folks. As soon as you post a silly question you find the answer yourself. Missing tag lib in web.xml. arggggggggggghhhhhhh! I'm out!
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vic Newman:
Missing tag lib in web.xml.



Actually, you should not need the taglib element in the web.xml.

All you need to do is include the appropriate taglib directive on the page with the appropriate URI to the JSTL.

Less is more -- why put declarations in the web.xml if you don't have to?
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vic Newman,

Once again check your useBean tag in your JSP page. there is no information regarding Class type. you simply type as java.util.List. then how JSP will get data?

With regards,
Prasad
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Prasad Babu Dandu:

Once again check your useBean tag in your JSP page. there is no information regarding Class type. you simply type as java.util.List. then how JSP will get data?



What Vic has done in this regard is perfectly sensible. Moreover, this doesn't really have anything to do with the question he asked.
[ March 23, 2006: Message edited by: Bear Bibeault ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic