wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Error while Coding TagLibs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Error while Coding TagLibs" Watch "Error while Coding TagLibs" New topic
Author

Error while Coding TagLibs

ajay vasudevan
Greenhorn

Joined: Apr 23, 2005
Posts: 21
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

Joined: Jul 20, 2005
Posts: 215
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

Joined: May 11, 2004
Posts: 298
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"%>


Kapil Munjal
SCJP 1.4, SCWCD 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error while Coding TagLibs