I want to use JSTL
I tried to import taglib using:
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
but it says cannot find tag library descriptor for
You can find link to download page in jstl FAQ. Choose the version you need and download necessary dependencies.
Related
(server Tomcat7v)
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
First Name:<c:out value="${param.fname}"></c:out><br/>
Last Name:<c:out value="${param.lname}"></c:out>
in the previous JSP and I am getting
Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
this error.
But when I try to find out the jars there were lots of version of that I am confused with which one should I use??
You need to put jstl jar in your classpath. See details at https://stackoverflow.com/tags/jstl/info
I were using Tomcat 7v which uses servlet 3.0 so I had to use jstl1.2.1 jars
I imported a web project build in JSP, which I am relatively new to. I got some errors in WEB-INF/includes/components that I am unable to resolve.
Some .jspf files show me errors such as at that line:
<c:if test="${fn:length(view.parent.views) > 1}">
the error is:
Multiple annotations found at this line:
- The function fn:length is
undefined
- Unknown tag (c:if).
I also get errors like The function fn:length is undefined errors for fn:length.
I followed up with other questions and made sure that standard.jar and jstl-1.2.jar are included in my build path. Moreover, WEB-INF/includes/taglibs.jspf has the following :
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
It works if I add the following at the beginning of my JSP file:
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%# taglib prefix="nav" uri="/WEB-INF/taglibs/navigation.tld" %>
<%# taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
This is a working answer for now, but I think the best answer would be the one that tells how it can be sufficient to include the lines above in taglibs.jspf, instead of having them in every .jsp file.
I recently faced same problem. I added a base.jspf file and referred it on the top of the file:
<%# include file="/WEB-INF/includes/base.jspf" %>
That file contains
<%# taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
I have got the following errors and i am unable to find an answer. Can someone help me here.
Description Resource Path Location Type
Can not find the tag library descriptor for "http://www.springframework.org/tags" contact.jsp /Spring3HibernateMaven/src/main/webapp/WEB-INF/jsp line 1 JSP Problem
Description Resource Path Location Type
Can not find the tag library descriptor for "http://www.springframework.org/tags/form" contact.jsp /Spring3HibernateMaven/src/main/webapp/WEB-INF/jsp line 2 JSP Problem
My JSP code is as follows;
<%# taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%# taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
In my Web.xml the code is as follows;
<jsp-config>
<taglib>
<taglib-uri>http://www.springframework.org/tags/form</taglib-uri>
<taglib-location>spring-form.tld</taglib-location>
</taglib>
</jsp-config>
How do i solve this error ?
You shouldn't need to configure the taglib in web.xml. Just make sure the org.springframework.web.servlet-xxx.jar is on your classpath (web-inf/lib). It contains the TLD files.
I have the same problem although I have already spring-webmvc-3.1.0.RELEASE.jar on Maven repos.
When I download jar org.springframework.web.servlet-3.1.0.RELEASE.jar and include in lib. It works.
I don't know why because two jars were totally the same, they just have different names.
Guys i have included jstl and standard.jar in lib directory under classpath. It says absolute uri http://java.sun.com/jstl is not found either in web.xml or in application. please let me know how to configure in websphere 5.1.2
The right taglib URI depends on the JSTL version. Assuming you're using JSTL 1.1 (which would be the best choice for WAS 5.1.2 which runs Servlet 2.3), you need to specify taglib URI's as per this document. So, JSTL core should be specified as follows:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
(note the extra /jsp path; this is added in JSTL 1.1 as opposed to JSTL 1.0)
I seem to remember reading that it's possible to declare taglib directives such as:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
in web.xml. This eliminates the need to duplicate this directive in every JSP file where the taglib is used. Could someone tell me how these directives can be added to web.xml?
The taglib element in web.xml serves a different purpose to the taglib directive which you have above.
As David said, the taglib directive is required on each page.
If you have many pages which use common taglibs, you can shortcut this by putting the taglib directives into an include file, and including this file each page. But no matter how you do it, the taglib directive has to be on the page somehow.
That tag you need to include on each page looks like this:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
If you have a custom taglib in a custom location, you can also specify a location relative to the webapp root:
<%# taglib prefix="ex" uri="/taglib.tld" %>
Further reading on the taglib directive
The taglib directive from web.xml maps tag uris to the physical location of your taglib. It is optional since JSP 2.0, as compliant containers will look in a set of standard locations to try to auto-discover the taglib: /WEB-INF and its subdirectories, /META-INF as well for JAR files.
It looks like this, in web.xml:
<taglib>
<taglib-uri>
http://www.example.com/taglib
</taglib-uri>
<taglib-location>
/taglib.tld
</taglib-location>
</taglib>
And the taglib is referenced in the JSP page like this (the taglib directive on each page is unavoidable!):
<%# taglib prefix="ex" uri="http://www.example.com/taglib" %>
This is equivalent to the second example I gave for the taglib directive above. The biggest difference is in how you point to the taglib location.
This page contains a bit more information.
Sorry, you're slightly mistaken. If a page uses a taglib, you have to have a taglib directive for it on the page. You could place the common taglib directives in an include file that all of your pages include with an include directive, but at compile time the taglib directive has to be there.
I prefer to NOT have the taglib elements in the web.xml, and instead have the taglib directive specify the URI value that is used in the "uri" element in the TLD that is inside the taglib jar file in your WEB-INF/lib.