Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while Coding TagLibs

 
ajay vasudevan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear all,
please help me with this problem.
i wrote a code using tag <c:forEach></c:forEach>
but i am getting the following error :

org.apache.jasper.JasperException: /jsp/jstl/JSTLpage.jsp(5,0) No tag "forEach" defined in tag library imported with prefix "mine"

i am sending the code as well.

<%@ taglib prefix = 'mine' uri = 'DiceRoller'%>
<html>
<body bgcolor="red">
<table align = 'center'>
<mine:forEach var = 'bks' items='${requestScope.books}'>
<tr>
<td>${bks}</td>
</tr>
</mine:forEach>
</table>
</body>
</html>

i have appropriately copied jstl.jar in ROOT/web-inf folder.
my tld file is as follows which is in ROOT/web-inf/lib folder.

<?xml version="1.0" encoding="ISO-8859-1"?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<tlib-version>1.2</tlib-version>
<uri>DiceRoller</uri>
<function>
<name>RollDiceTLD</name>
<function-class>TLD.RollDiceJava</function-class>
<function-signature>int rollDice(int)</function-signature>
</function>
</taglib>

please help me with this problem.

thanking you,

ajay vasudevan
scjp 1.4
 
Mat Williams
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What you have done is create a tld with the uri="DiceRoller"
the only method defined in the tld is 'RollDiceTLD'

you have mapped the prefix 'mine' to the uri 'DiceRoller' therefore in your page the only tag you can call from the page with the prefix of mine is RollDiceTLD

to be able to call forEach you will need to either
1) add a new <%@ taglib prefix='somthing_other_than_mine' uri='uri_for_forEach'%> (the uri escapes me at the moment but I know it is in HFSJ
OR
2) change <%@ taglib prefix='mine' uri='correct_uri_for_forEach'%>

HTH

Mat
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you are trying to use is mix your tag with the already defined tag library which is here jstl.jar.

Try using <c:forEach> in place of <mine:forEach>

and include this taglib also

<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic