Forums Register Login

Wrong output : custom tag libraries

+Pie Number of slices to send: Send
I have been executing some simple tags in tomcat5 and I have been getting the right output. So, this one is baffling me as I cannot find the source of the error. Anyway, here are the details...

custom1.tld --->

<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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<short-name> Custom tag 1 </short-name>
<tlib-version>1.0</tlib-version>

<uri>custom1</uri>

<tag>
<description> Worst use of a custom tag </description>
<name>custom1</name>
<tag-class>foo.CustomTagTest1</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>



CustomTagTest1.java -- >

package foo;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import java.io.IOException;
import javax.servlet.jsp.JspWriter;


public class CustomTagTest1 extends TagSupport {

public int doStart() throws JspException {

JspWriter out = pageContext.getOut();

try {
out.println("IS it coming here");
out.println("Lamest excuse for a Tag");

} catch(IOException ie) {
throw new JspException("Io Exception throw is " + ie);

}
return SKIP_BODY;
}
}

CustomTagTest1.jsp -- >

<html>
<body>
<%@ taglib prefix="mine" uri="custom1" %>

Calling my own custom tag 1 <br>

<mine:custom1 />

After calling the tag

</body>
</html>


I am getting the output as

Calling my own custom tag 1
After calling the tag

whereas it should be

Calling my own custom tag 1
IS it coming here
Lamest excuse for a Tag
After calling the tag



What am I missing ? I know its a pain to read all this code but I just can't figure out what I am doing wrong. Appreciate anybody's help. Thanks.
+Pie Number of slices to send: Send
Its doStartTag() not doStart()
+Pie Number of slices to send: Send
Wasn't that stupid ? Thanks anyway, Naresh!
I knew I would regret that burrito. But this tiny ad has never caused regrets:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 530 times.
Similar Threads
JSP EL not working
Classic Tag Handler problem
Classic Tag Handler problem
taglib problem in Netbeans
cannot find the declaration of element taglib
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:12:04.