Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrong output : custom tag libraries

 
Ritu varada
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Naresh Arige
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its doStartTag() not doStart()
 
Ritu varada
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wasn't that stupid ? Thanks anyway, Naresh!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic