Originally posted by Bear Bibeault:
You need a taglib directive at the top of each JSP page that will use the taglib. This directive identifies the URI of the taglib (which must be stored somewhere the container can find it) and associates it with a tag prefix.
Under some circumstances, you may need to define the taglib in web.xml.
[ March 09, 2004: Message edited by: Bear Bibeault ]
Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Originally posted by Al Kaiser:
Thanks for the information. Is taglib.tld file is different for each custom JSP files containg tags?
Also, Is the follwing code legal. I'm getting error on this even if I register the taglib containg in the JAR file:
(...)
</title>
</head>
<body>
<c:setFeed url="http://www2.theserverside.com/rss/theserverside-1.0.rdf" id="A"/>
<p>Title:<c:getChannelTitle feedId="A"/>
<p>Description:<c:getChannelDescription feedId="A"/>
<c:forEachItem feedId="A">
Link:<%=itemLink%>
(..)
the error in the output:
x Error(12): c:setFeed is not a registered tag in that namespace.
Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
Originally posted by Nicholas Cheung:
You should also *import* the JSTL tag library into the JSP with the taglib directive.
Nick.
[ March 09, 2004: Message edited by: Nicholas Cheung ]
Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
Originally posted by Hans Bergsten:
Nick.
[ March 09, 2004: Message edited by: Nicholas Cheung ]<hr></blockquote>
Actually, this taglib directive only works if you have the TLD in a file name WEB-INF/c.tld, and there's no reason to put it there because it's already included in the standard.jar file (in you use the reference implementation) in WEB-INF/lib.
You should always use the default URI for the JSTL libraries, e.g.:
for JSTL 1.0 or
for JSTL 1.1.
Not only is it easier to install (just put the JAR files in WEB-INF/lib), but it's also the only way for the container to realize that you're using JSTL so it can optimize the code it generates for the page. Some containers can, for instance, generate a simple if statement for the <c:if> action if it knows that it's a JSTL action instead of the more complex code for creating a tag handler instance, configuring it with attribute values and invoking its doXXX() methods. This type of optimization is only enabled when you use the standard URIs for the JSTL libraries.[/QB]
When I add the ...\jstl\core lib tag, I get the following error:
x Error(2): "http://java.sun.com/jsp/jstl/core" is not a registered TLD namespace.
x Error(6): Unable to find class for bean: quote defined by tag with class: Request
Does that mean I need to download those core libraries? From where though?
Originally posted by Al Kaiser:
Might be related to my previous questions, I'm getting error in the following page. Should I place the JAR's and .class files in the same basket - which is ..\web-inf\lib. Please let me know?
---
<%@ page contentType="text/html;charset=windows-1252"%>
<html>
<br><b>Quotes page</b>
<%@ page language="java" import="Request" %>
<jsp:useBean id="quote" class="Request" scope="page" />
<%
String s="";
java.util.Vector v;
(....)
Error(5): Unable to find class for bean: quote defined by tag with class: Request
Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
Originally posted by Al Kaiser:
[QB]Hans,
When I add the ...\jstl\core lib tag, I get the following error:
x Error(2): "http://java.sun.com/jsp/jstl/core" is not a registered TLD namespace.
x Error(6): Unable to find class for bean: quote defined by tag with class: Request
Does that mean I need to download those core libraries? From where though?
Al
Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
Earlier versions of the SDK incorrectly allowed beans in the default (unnamed) package to be used in JSP pages, but from 1.4 and on, it's no longer possible.
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Originally posted by Nicholas Cheung:
Hi Hans,
I remember so posts before, saying that classes in default package do not work, while they work when they are in non-default packages.
That is to say, if I use JDK 1.3.x together with Tomcat 4 or 5, it will still work, but if I use JDK 1.4.x, together with Tomcat 4, it will not work?
Nick.
Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0