Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with tag file

 
salil verma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was testing the approach of tag file ..

I made the following tag file (Tagtest.tag)
<h1> this is from tag file </h1>

and following tld file (Tagtest.tld)
<?xml version="1.0" encoding="UTF-8"?>
<taglib>
<tlib-version>1.0</tlib-version>
<uri>MyVersion</uri>

<tag-file>
<name>NameOfTagFile</name>
<path>/WEB-INF/tags</path>
</tag-file>
</taglib>


added the following entry in web.xml file
<taglib>
<taglib-uri>MyVersion</taglib-uri>
<taglib-location>/WEB-INF/Tagtld.tld</taglib-location>
</taglib>

and used the follwing code as a jsp file

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib prefix="c" uri="MyVersion"%>
<HTML>
<HEAD>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet" type="text/css">
<TITLE>Tagjsp.jsp</TITLE>
</HEAD>
<BODY>
<P> About to include the content from the tag file </P>
<c:NameOfTagFile/>
</BODY>
</HTML>

but when i try to run the jsp file i get the follwing error message
"Unable to locate tag library for uri MyVersion"

I have put the tag file in /WEB-INF/tags and tld file in /WEB-INF directory.I am using websphere server as environment. using jsp 2.4 environment.
Can any one help me resolve this problem.
 
Nigel Chou
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you may try to use <%@ taglib prefix="c" tagdir="......"%> instead of <%@ taglib prefix="c" uri="MyVersion"%> And remove anything about it in TLD and DD
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got an example of a working JSP Custom tag library created with IBM's Rational Application Developer here:

Tutorial on Creating a Custom Tag with IRAD and WebSphere

Here's also an EAR file containing a single tag library that indeed works, just in case you want a working reference:

Working EAR with a Simple Custom Tag

There are three key things you might want to doublecheck:

1. Entry in the jsp
2. Creating of tld
3. Reference in the web.xml?

public class TimerTag extends TagSupport {



I'm going to compare that to your code.

Frustrating, isn't it?

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic