This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

CustomTag

 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,
Do i need to include any special JAR file for testing Custom Tag handler.I tried to use SimpleTagSupport class, but I cannot find that in the library.

thanks
Shashank
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No ,
If you are using JSTL , yes you need to add a few classes to your source path.
But for custom tags, you dont need to install anything extra other than the jdk and the web container/J2ee container.
So if a normal servlet program , JSP program runs, then there is some other problem with your code.
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, only things you need are JSP page, tld file and Tag handler
Try this

customTag.jsp

<%@ taglib prefix="myTags" uri="simpleTag"%>
<html><body>
<myTags:simple1/>
</body></html>


SimpleTag.tld

<?xml version="1.0" encoding="ISO-8859-1" ?>

<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">

<tlib-version>0.9</tlib-version>

<short-name>simpleTags</short-name>
<uri>simpleTag</uri>
<tag>
<description>Use of custom tags</description>
<name>simple1</name>
<tag-class>com.example.web.SimpleTagTest1</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>


com/example/web/SimpleTagTest1.java
package com.example.web;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
import javax.servlet.jsp.JspException;
public class SimpleTagTest1 extends SimpleTagSupport{
public void doTag() throws JspException,IOException{
getJspContext().getOut().print("This is the use of custom tag");
}
}
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic