Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tag files in jar...how??

 
Kuppusamy Venkatasubramanian
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I wish to use tag files using jar file. Below are my files..

//TagExample.jsp ...referring the tag file

This is an example of tag.
<%@ taglib prefix="myTag" uri="tagloc" %>
<myTag:Header headerVal="<h1>This part constitues header</h1>" />
<myTag:Body color="Red">
Our company is a startup company and we are hopeful that in two years time,
our company will be listed in NASDAQ. Kindly invest in our company. We are
searching for investors.
</myTag:Body>
<myTag:Footer footerVal="Copyright of our company" />

//This the tld..
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlib-version>1.2</tlib-version>
<jspversion>2.0</jspversion>
<uri>tagloc</uri>
<tag-file>
<description> TLD for tag files </description>
<name>Header</name>
<path>/META-INF/tags</path>
</tag-file>
</taglib>

//This is how i created the jars..
jar cvf tags.jar META-INF\tags\Header.tag

I am getting null pointer exception in tomcat...what to mention in name tag in tld..

Thanks in advance..
SAM..
 
Kuppusamy Venkatasubramanian
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kuppusamy Venkatasubramanian:
Hi,

I wish to use tag files using jar file. Below are my files..

//TagExample.jsp ...referring the tag file

This is an example of tag.
<%@ taglib prefix="myTag" uri="tagloc" %>
<myTag:Header headerVal="<h1>This part constitues header</h1>" />
<myTag:Body color="Red">
Our company is a startup company and we are hopeful that in two years time,
our company will be listed in NASDAQ. Kindly invest in our company. We are
searching for investors.
</myTag:Body>
<myTag:Footer footerVal="Copyright of our company" />

//This the tld..
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlib-version>1.2</tlib-version>
<jspversion>2.0</jspversion>
<uri>tagloc</uri>
<tag-file>
<description> TLD for tag files </description>
<name>Header</name>
<path>/META-INF/tags/Header.tag</path>
</tag-file>
</taglib>

//This is how i created the jars..
jar cvf tags.jar META-INF\tags\Header.tag

I am getting null pointer exception in tomcat...what to mention in name tag in tld..

Thanks in advance..
SAM..


-----
Hi has any one tried the above. When i checked the spec it is saying that there should be a name element in tld referring to the tag filename without .tag extention. I mentioned that also but what to mention in <uri> element in the tld. Besided does there need to be an element in web.xml that maps tagdir"/WEB-INF/tags" to a uri in the tld.

SAM..
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this in web.xml

 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Where you place the .tld file for this tag file? I think it must be under META-INF directory in the same .jar file. Create .jar file from the sub-directory where you place the META-INF directory. The jar file shuold contain .tag and .tld file.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic