• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL Problem

 
Vic Newman
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<cut value="${value}" default="no value available"/></tr></td>
</c:forEach>

<c:forTokens items="a;b;c;d" delims=";" var="current">
<tr><td><cut 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<cut value="" default="no value available"/></tr></td>
</c:forEach>

<c:forTokens items="a;b;c;d" delims=";" var="current">
<tr><td><cut 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!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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?
 
Prasad Babu
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
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic