I’m using java server pages for the first time and I’m having a problem with tags. I am also working in Eclipse, if that’s relevant.
The specific error I’m getting is:
org.apache.jasper.JasperException: /Query.jsp (line: 5, column: 0) No tag "choose" defined in tag library imported with prefix "c"
The problem is, there is a tag “choose” with a prefix c…
I was having trouble with the urls that are usually recommended, it seems some of them are outdated, so I downloaded the standard tags and extracted them into my WEB-INF/tags directory.
My jsp file starts out with:
<%@ page contentType="text/html" import="beans.*" %>
<%@ taglib prefix="c" tagdir="/WEB-INF/tags/c.tld" %>
<%@ taglib prefix="sql" tagdir="/WEB-INF/tags/sql.tld" %>
<%@ taglib prefix="fn" tagdir="/WEB-INF/tags/fn.tld" %>
<c:choose>
....
c.tld has:
...
<tag>
<description>
Simple conditional tag that establishes a context for
mutually exclusive conditional operations, marked by
<when> and <otherwise>
</description>
<name>choose</name>
<tag-class>org.apache.taglibs.standard.tag.common.core.ChooseTag</tag-class>
<body-content>JSP</body-content>
</tag>
It’s my guess that there’s some sort of configuration error somewhere, but I’m totally clueless about where it might be.
Your taglib declarations are wrong. Replace this:
with this:
and make sure it’s not (as some ancient tutorials say):
… and repeat for the other libraries. You don’t need your own copies of the
.tldfiles, they’re no longer required.I’m not sure where you got that from, but almost any JSP/servlet engine will work with the URIs I mentioned. If those URIs don’t work, then post a new question to that effect. Downloading your own
tldfiles is almost certainly not the correct approach.