taglib not working

I am trying to get my first taglib to work in my webapps:

Tomcat 5.5\webapps\myfirst

I keep getting error message when I pull up my servlet that is calling my jsp:

org.apache.jasper.JasperException:

The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

Here is my jsp:

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

<html>

<body>

<c:forEach var="city" items="${requestScope.city}">

......

</c:forEach>

</table>

</body>

</html>

I am not sure if I need to add some sort of taglib info in my web.xml or what I need to do to get taglib to work?

[925 byte] By [oaklandara] at [2007-10-3 1:27:23]
# 1

You require extra library files over the standard Tomcat ones to run the JSTL.

Specifically standard.jar and jstl.jar need to be in the WEB-INF/lib directory.

You can get them from here:

http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html

http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi

evnafetsa at 2007-7-14 18:24:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

In web.xml add these entries ...

<taglib>

<taglib-uri>c.tld</taglib-uri>

<taglib-location>/WEB-INF/tld/c.tld</taglib-location>

</taglib>

make sure that you have extracted the tlds in the mentioned path.

In your jsp add this line

<%@ taglib uri="c.tld" prefix="c" %>

You can download the tag libraries from the links evnafets has mentioned.

Rgds

-Rohit

RohitKumara at 2007-7-14 18:24:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

> In web.xml add these entries ...

>

No that's not required. Just specify the uri attribute in your jsp

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

And place standard.jar and jstl.jar in WEB-INF/lib. The container will auto discover the tag library and the tlds at runtime. The uri resolves to the uri attribute of the tag library tld.

ram.

Madathil_Prasada at 2007-7-14 18:24:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Thanks I downloaded what you suggested in my web-lib (Tomcat 5.5\webapps\test\WEB-INF), the taglib part I think is working but now I get just the variables showing on the jsp but no errors on the page:

Customer List Id First Name Last Name Address

${customer.id} ${customer.firstName} ${customer.lastName} ${customer.address}

I tried this:

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

and this:

<%@ taglib uri="c.tld" prefix="c" %>

It should show the customer values but for some reason it not showing.

oaklandara at 2007-7-14 18:24:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

hi

do one thing you change in web.xml as follows u should mention the version

u just do one thing copy the following and paste in web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app 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">

i hope it will work because the expression language will work this version effectively

Cheers,

Aleem Basha

aleem@1241a at 2007-7-14 18:24:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

It still gives the same output. It doenst seem to want to show the variable values.

Here is my web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app 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">

<description>Configuration file for website</description>

<servlet>

<servlet-name>Tester</servlet-name>

<servlet-class>Tester</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Tester</servlet-name>

<url-pattern>/Tester.soccer</url-pattern>

</servlet-mapping>

<servlet>

<servlet-name>controller</servlet-name>

<servlet-class>SimpleController</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>controller</servlet-name>

<url-pattern>/controller</url-pattern>

</servlet-mapping>

</web-app>

My taglib line:

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

oaklandara at 2007-7-14 18:24:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

I'll assume standard.jar and jstl.jar are in place, that means in your WEB-INF/lib directory. Try two things, if you're using Tomcat 5.5.x:

change this:

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

into this

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

an then, (don't laugh I'm serious) change the string "version=2.4" to the beggining of web-app tag. This strange exchange, saved me from this very same problem. I must admit I could not believe it ( i read this solution on this forum) untill I saw it worked.

So, it would be like this: (version first) . Just give it a try and you'll see.

<web-app version="2.4" 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">

MarcioBarrosoa at 2007-7-14 18:24:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

hi Mr.oaklandar

You just send what is your output .

in your web.xml where is

<taglib>

<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>

<taglib-location>/WEB-INF/c.tld</taglib-location>

</taglib>

you should specify the location of the tld file either above or with out mentioning in

web.xml as follows

<@taglib uri="/WEB-INF/c.tld" prefix="core">

try this dont forget to mention the version in web.xml

try this it may help u

let me know what are getting the out pue

write clearly i may help u

cheers,

Aleem Basha

aleem@1241a at 2007-7-14 18:24:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

Thanks it now works great.

Do I have to load extra library files for every web app where I have to put library files in each WEB-INF for each web project?

For example if I have it now working in my test webapp I would have to do the same with anotherProject by loading all the library files in the anotherProject WEB-INF folder?

C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\test\WEB-INF

C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\anotherProject\WEB-INF

oaklandara at 2007-7-14 18:24:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

hi

You can do one thing u can direcly place the jar files in

C:/ProgramFiles/Tomcat5.5/commons/lib

in this one u can place all the jar files which will use to your projects because

these jar files automatically loaded when the server stats

i hope it may help u

Cheers,

Aleem Basha

aleem@1241a at 2007-7-14 18:24:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...