• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error While Creating Custom Tags

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I was going through the following link which explains how to create JSP custom tags and everything seems to be working fine except for an error in my JSP file.

Link: http://www.ibm.com/developerworks/java/library/j-pj2ee8/

The error I got is:

JspTranslate: : XML parsing error on file /WEB-INF/lib/DateTagLib.tld: (line 2, col 9): Document root element "taglib", must match DOCTYPE root "null"..

Any idea on what is causing this error?

Btw, the tld file, I created a new xml file and named it as .tld instead of .xml. Am I doing it right?

My Jsp file is as follows:
<blockquote>code:
<pre name="code" class="core"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/lib/DateTagLib.tld" prefix="abc" %>
<HTML>
<HEAD>
<TITLE>Date tag example</TITLE>
</HEAD>

<BODY>
<H1>Date tag Example</H1>
<p>Hi today is <b><abc:displayDate /></b> </p>
</BODY>
</HTML>

</pre>
</blockquote>

Thanks.
[ July 17, 2008: Message edited by: Arjun Reddy ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the problem is with the tld file, don't you think that's what you should be showing us?
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um.. Okie.. sorry.

<blockquote>code:
<pre name="code" class="core"> <?xml version="1.0" encoding="UTF-8"?>
<taglib>
<tlibversion>1.0</tlibversion>
<info>A simple tag library</info>
<tag>
<name>displayDate</name>
<tagclass>myTags.DateTag</tagclass>
<bodycontent>empty</bodycontent>
<info>Display Date</info>
</tag>
</taglib>
</pre>
</blockquote>

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there really as space before the XML declaration? Is this for a JSP 2.0 application? If so, where's the rest of the taglib declaration (xmlns and so on?)

Here's the first 6 lines of one of my tld file:
<blockquote>code:
<pre name="code" class="core"><?xml version="1.0" standalone="no" ?>

<taglib 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/web-jsptaglibrary_2_0.xsd"
version="2.0">
</pre>
</blockquote>
[ July 17, 2008: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic