It's not a secret anymore!
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

Error while Coding TagLibs

ajay vasudevan

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'%>
<body bgcolor="red">
<table align = 'center'>
<mine:forEach var = 'bks' items='${requestScope.books}'>

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=""
<function-signature>int rollDice(int)</function-signature>

please help me with this problem.

thanking you,

ajay vasudevan
scjp 1.4
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215

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
2) change <%@ taglib prefix='mine' uri='correct_uri_for_forEach'%>


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 = ""%>

Kapil Munjal
SCJP 1.4, SCWCD 1.4
I agree. Here's the link:
subject: Error while Coding TagLibs
It's not a secret anymore!