Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

JSTL Problem

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
Marshal
Posts: 67366
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
Marshal
Posts: 67366
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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 ]
 
knowledge is the difference between drudgery and strategic action -- tiny ad
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!