• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Not able to access JSTL tags

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ..

I am new to JSTL.I am using Tomcat 4.1.24 and Java 1.4

I have copied jstl.jar and standard.jar(includig dependancy jar files) into WEB-INF\lib folder.

I've placed all the *.tld file under WEB-INF\taglib folder

this is the web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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">


<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>;
<taglib-location>/WEB-INF/taglib/fmt.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>;
<taglib-location>/WEB-INF/taglib/c.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>;
<taglib-location>/WEB-INF/taglib/sql.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://java.sun.com/jstl/x</taglib-uri>;
<taglib-location>/WEB-INF/taglib/x.tld</taglib-location>
</taglib>



<display-name>Hello World!</display-name>

</web-app>

JSP is my JSP : jstlcore.jsp

<%@ taglib prefix="c" uri="\WEB-INF\taglib\c.tld" %>

<html>
<head>
<title>Simple Example</title>
</head>
<body>

<c:set var="browser" value="${header['User-Agent']}"/>
<c ut value="${browser}"/>

</body>
</html>

When I run this jstlcore.jsp in browser I got the following error.

org.apache.jasper.JasperException: XML parsing error on file \WEB-INF\taglib\c.tld: (line 3, col 8): Document is invalid: no grammar found.
at org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:189)
at org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:243)
at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:183)

I tried changing the URI in jsp to
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

I got the different error
org.apache.jasper.JasperException: This absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:105)


please some one help me to solve this..
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where to start?
1 - All you need to use JSTL is the two jar files in the web-inf/lib directory.
- NO tld files
- NO entries in web.xml
- NO PROBLEM!

2 - You have Tomcat4. Tomcat4 is a Servlet2.3/JSP1.2 container.
You have declared your web.xml file as supporting Servlet2.4.
Obviously that won't work. Change it to the standard 2.3 DTD.
Look in [TOMCAT]/webapps/ROOT/web-inf/web.xml for an example

So as a result of the changes, your web.xml should look something like this.



With Tomcat4, you need to use JSTL1.0. Make sure you have downloaded the correct version.
Import it into your webpage with the following tag:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

If you have fixed up your web.xml and removed the extra tld files, it should work at this point.

Cheers,
evnafets
 
selvi family
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much..I got it..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic