wood burning stoves 2.0*
The moose likes IDEs, Version Control and other tools and the fly likes Error with JSTL tags in eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Error with JSTL tags in eclipse" Watch "Error with JSTL tags in eclipse" New topic
Author

Error with JSTL tags in eclipse

Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
I have Eclipse Version: 3.4.1. In my JSP's I have the following taglibs

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

Eclipse shows a error
"Cannot find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"

And i have few c:when and c:if tags. Eclipse shows
Unknown tag (c:when).

Can anyone please let me know how to get eclipse working for JSTL tags.
Thanks
Deepak
[ November 21, 2008: Message edited by: Deepak Jain ]

SCJP, SCWCD, SCBCD
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
I have included standard.jar , jstl.jar into the build path of the eclispe project, I still get the same error.
Any help is appreciated.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Adding standard.jar to the build path for your project should do it. Double-check the standard.jar that it contains the *.ltd files. Also, try closing and reopening the JSP - sometimes the editors get "stuck" and reopening the file helps.


JBoss In Action
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Eclipse shows a error
"Cannot find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
The above error is resolved.

I still see below errors.

And i have few c:when and c:if tags. Eclipse shows
Unknown tag (c:when).

Any help is appreciated
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
It worked after restarting eclipse & box
The only thing one has to do is included standard.jar, jstl.jar into the build path of the eclispe project.
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
One new problem.
I have defined a tld with few EL Functions.

1) There was no option in Eclipse to "Create a new TLD file", like "Create a new Java class file"
2) So i did it manaully. Later to use the tags defined in the TLD, in my JSPs, i defined it using taglib. There was no autocomplete when i tried to invoke the EL functions. ${prefix: functionName()} There was no autocomplete after prefix not after ${.
Is JSTL, Custom tag support limited in eclipse. If not how can one get complete support with autocomplete features.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

In order to get autocomplete and validation to work in Eclipse, you need to ensure that the TLD or schema is accessible under the right key by Eclipse itself (regardless of classpaths). Eclipse supports an XML catalog for such files which you should be able to find under the Preferences/XML dialog.

Some Eclipse web development bundles will have pre-cataloged TLDs/schemas for the JEE-related items. If you develop a custom TLD, you must manually catalog it.


Customer surveys are for companies who didn't pay proper attention to begin with.
Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Hi,

I had the same problem. my custom tags were marked as "Unknown tag"
I did not add any catalog for tld files.
I just installed the following version, then works fine.

Eclipse Version: 3.3.0
Build id: M20070921-1145

Kathir
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Thanks guys.
I added the TLD file to the catalog and still there was no autocomplete after ${prefix:}
Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Hi Deepak,

Did you try the Exclipse 3.3.0 ?
It does autocomplete.

Kathir
jonathan mckeever
Greenhorn

Joined: Mar 06, 2009
Posts: 1

I continue to get "Cannot find the tag library descriptor" errors when trying to compile with Eclipse.

Cannot find the tag library descriptor for "http://java.sun.com/jstl/core"

I am running JDK 1.4 / Tomcat 5.0 and Eclipse 3.4.2 EE, with Web Tools 2.2
I have made sure that the jstl.jar and the standard.jar are in the WEB-INF/lib. I even downloaded two new jars (JSTL 1.1) and Standard.jar and swapped them in.

These errors are at compile time. Not run time. Tomcat has nothing to do with it.

I have this exact configuration set up on my other machine and its working fine. The only difference is that this is Eclipse 3.4.2 EE version.

Any ideas how I can fix this?
sandeep raj
Greenhorn

Joined: Mar 06, 2009
Posts: 10
I am kindof having the same problem. i am using eclipse 3.4.1 with tomcat .
Like deepak mentioned i did not find any support in eclipse for creating tld files so i created a file on my own and added it to the WEB-INF folder. here is the code -


i get the following error - XML document structures must start and end within the same directory

my jsp page is as follows


eclipse is unable to find the tld descriptor for "DiceFunctions"

i added standard.jar and jstl.jar in the build path though i dont think i need them. I also tried adding the tld to the xml catatlog but that didnt work either so if anyone knows any solution to the problem please let me know..
The code is basically taken from the head first servlets book where EL functions are described.
andyx hung
Greenhorn

Joined: Mar 26, 2009
Posts: 1
try this...


Nick Potter
Ranch Hand

Joined: May 07, 2008
Posts: 126
Eclipse has a strange bug (?) when it comes to JSTL. It doesn't find the c.tld from the jstl jar (for JSTL 2.0 and on, i believe). So extract the c.tld from the jstl.jar and put it somewhere in the WEB-INF, for example in WEB-INF/tlds. The use this uri for @taglib in your jsps. You shouldn't have any problems.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Steps to install JSTL:
1) Place the JAR file(s) in classpath. A path covered by default classpath is /WEB-INF/lib (and certainly not /WEB-INF). Place the file(s) in there.
2) Declare the JSTL taglib URI in JSP according to the JSTL version. There are 3 different URI's available. Make sure that you use the right one. Read the TLD documentation for details. Make sure that you read the right TLD for the right version.

Only those two steps are to be done. Really. Do NOT extract the JAR files and clutter the classpath or WEB-INF with loose files. Do NOT clutter the web.xml with separate tld declarations. Eclipse doesn't have any bugs related to JSTL. It's just all your own fault.

The JSP FAQ at this website contains more details such as JSTL download links and correct taglib URI's.
Nick Potter
Ranch Hand

Joined: May 07, 2008
Posts: 126
I wasn't able to use the default uri when i started a normal project (not web project).
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
It was your fault that you didn't create a web project.
Nick Potter
Ranch Hand

Joined: May 07, 2008
Posts: 126
Actually no
swaroop rath
Greenhorn

Joined: Jul 24, 2009
Posts: 11
Guys guys guys

I had this terrible problem, trying to use eclipse for El, creating tld, custom tags etc. The support is horrible. (Actually there is none)

I tried something else and it rocks - netBeans.

This has all the features we want. It has excellent wizards for deployment descriptors, tlbs, custom tags etc. Give it a try.

Rgds
Swaroop
Brad Thurber
Greenhorn

Joined: Aug 26, 2009
Posts: 1
Make sure you have the JSTL facet enabled

right-click your project/properties/Project Facets select the JSTL checkbox and version (possibly 1.1 in your case?)

Deepak Jain wrote:I have Eclipse Version: 3.4.1. In my JSP's I have the following taglibs

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

Eclipse shows a error
"Cannot find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"

Pravin Bansal
Greenhorn

Joined: Nov 16, 2009
Posts: 2
Folks,

Eclipse error "Cannot find the tag library descriptor for "http://java.sun.com/jsp/jstl/core" ideally have couple of reasons, most of them have been pointed out in the previous posts, the one and particularly important is as below. (which was actually the case with me)
Having this added in your jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
even after you have jstl.jar and standard.jar in the WEB-INF/lib directory, the only reason for this is the version of these two jar's.
defining taglib in the way "<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> " is required to have these jar's of version 1.2 (which are extracted from jakarta-taglibs-standard-1.1.2.zip) unfortunately you can never know the version of these jar's from their property
defining taglib in the way "<%@ taglib uri="http://java.sun.com/jstl/core" will require 1.0 version of these jar's.
Hope it helps.
Marco Antonio Toscano Freire
Greenhorn

Joined: Jan 05, 2010
Posts: 1
Hello Guys

There isn't any bug in Eclipse, the problem is the order of elements. Bellow show us either two forms:

Correct
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>


Incorrect

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


http://javecuador.blogspot.com
http://martosfre.blogspot.com

"Contigo todo lo puedo sin ti nada soy, mi Dios"
Tong Wang
Ranch Hand

Joined: Jun 20, 2005
Posts: 44
The order of the elements in the tag doesn't matter. Both forms below are correct.

In my case, after adding standard.jar to WEB-INF/lib, Eclipse 3.5 didn't pick up the change. So, I just entered a space in the JSP file, then removed it, then saved the JSP file, and it worked. Basically, the JSP didn't change, just edit it so it's "refreshed".

Marco Antonio Toscano Freire wrote:Hello Guys

There isn't any bug in Eclipse, the problem is the order of elements. Bellow show us either two forms:

Correct
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>


Incorrect

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


http://javecuador.blogspot.com
http://martosfre.blogspot.com
Sanju Manc
Greenhorn

Joined: May 28, 2009
Posts: 1
I'm using eclipse 3.4. I've imported web project into the eclipse. There are few custom tag libraries.

I could not get rid of the compilation errors in the eclipse
in tld files.
ERROR:The content of element type "tag" must match
"(name,tagclass,teiclass?,bodycontent?,info?,attribute*)".

I went thru previous topics and added jstl and standard jars in the build path of eclipse. I reopened eclipse IDE and restarted my machine, it did not help.

Can you pl. help in resolving this issue.



Nilesh Katore
Greenhorn

Joined: Mar 30, 2009
Posts: 3
Marco Antonio Toscano Freire wrote:Hello Guys

There isn't any bug in Eclipse, the problem is the order of elements. Bellow show us either two forms:

Correct
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>


Incorrect

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


http://javecuador.blogspot.com
http://martosfre.blogspot.com


It works.... good observation.... thanks
Aulac Smith
Greenhorn

Joined: May 27, 2010
Posts: 1
Nilesh Katore wrote:
Marco Antonio Toscano Freire wrote:Hello Guys

There isn't any bug in Eclipse, the problem is the order of elements. Bellow show us either two forms:

Correct
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>


Incorrect

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


http://javecuador.blogspot.com
http://martosfre.blogspot.com


It works.... good observation.... thanks


Actually both forms are correct. The problem is Eclipse does not refresh the jsp page properly. The solution is to do what Tong Wang did.

Cheers,

Aulac
Carl Douglass
Greenhorn

Joined: Aug 07, 2010
Posts: 1
The "correctly ordered" version changes the URLs themselves (dropping /jsp from both), and that is why the "correct" version works.
The order of the directives has nothing to do with it.
munish mehta
Greenhorn

Joined: Feb 15, 2011
Posts: 1
Do like this:
Download jstl.jar and standard.jar from archive at: http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/jakarta-taglibs-standard-1.0.1.zip

Extract these two jars from archive (present at jakarta-taglibs-standard-1.1.2.zip\jakarta-taglibs-standard-1.1.2\lib) and put into your classpath.

Now your taglib uri should match with <uri> value present in c.tld (present at jakarta-taglibs-standard-1.1.2.zip\jakarta-taglibs-standard-1.1.2\tld), which in this case is: http://java.sun.com/jsp/jstl/core

So your taglib will look like: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Similarly taglib uri will be: <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

Thanks
munish
manasa manogna
Greenhorn

Joined: Mar 29, 2011
Posts: 22
Yes the order doesn't matter here. Once the jstl.jar and standard.jar files are added to the "WEB-INF/lib" directory, cross check whether the Web App Libraries in your project's build path is checked in or not. Most probably, this will not be checked in and if it is the case, then select it and then build the project once again, this will solve the problem.
Robert White
Greenhorn

Joined: Mar 03, 2003
Posts: 8
I was having this problem in eclipse, but only with one of my jsps. When I compared the non-working file with the others I noticed this line missing from the top of the non-working file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

After adding that line, the error "Unknown tag (c:if)" went away.
G Par
Greenhorn

Joined: Jul 11, 2011
Posts: 9
Hey Guys,
You are not going to believe what I found. I had the same problem as everybody else has mentioned above. After 3 hours of trying all the solutions mentioned above and not success and almost uprooting all my hair I finally gave up on eclipse and went to netbeans and then guess what? I found some special characters in the file which I could not see in eclipse. Then I realized the tablib declaration that I had copied from some place was rich text and it put the " in some special form. It looked normal but I guess behind the scene it wasn't. Only after opening it in a different editor I could see it. Then removing th line and re-typing it directly in eclipse did the trick. Talk about wasting 3 hours of your life
But glad I could share it with you so nobody else go thru this again
Suhas Aithal
Greenhorn

Joined: Aug 10, 2011
Posts: 7
The order of the elements in the tag doesn't matter. Both forms below are correct.

In my case, after adding standard.jar to WEB-INF/lib, Eclipse 3.5 didn't pick up the change. So, I just entered a space in the JSP file, then removed it, then saved the JSP file, and it worked. Basically, the JSP didn't change, just edit it so it's "refreshed".



Thanks Tong Wang, works for me now.


stupid question right?? yeah thats me..
Javier Moreno
Greenhorn

Joined: Nov 18, 2011
Posts: 1
G Par wrote:Hey Guys,
You are not going to believe what I found. I had the same problem as everybody else has mentioned above. After 3 hours of trying all the solutions mentioned above and not success and almost uprooting all my hair I finally gave up on eclipse and went to netbeans and then guess what? I found some special characters in the file which I could not see in eclipse. Then I realized the tablib declaration that I had copied from some place was rich text and it put the " in some special form. It looked normal but I guess behind the scene it wasn't. Only after opening it in a different editor I could see it. Then removing th line and re-typing it directly in eclipse did the trick. Talk about wasting 3 hours of your life
But glad I could share it with you so nobody else go thru this again


Removing one space did the trick: <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> instead of "<%@ taglib"
 
 
subject: Error with JSTL tags in eclipse