• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Tag Compilation  RSS feed

 
Ramesh Bandaru
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have Tomcat 4.1.27 installed on my system.And am presently trying to write Custtom Tags.I have three files which are listed below:
Tag Class:
package coreservlets.tags;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class ExampleTag extends TagSupport {
public int doStartTag( ) {
try {
JspWriter out = pageContext.getOut( );
out.print("Custom tag example " +
" (coreservlets.tags.ExampleTag) ");
} catch(IOException ioe) {
System.out.println("Error in ExampleTag : " +ioe);

}
return(SKIP_BODY);
}
}
TLD File:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>csajsp></shortname>
<info>
A tag library from Core Servlets and JSP
</info>
<tag>
<name>example</name>
<tagclass>coreservlets.tags.ExampleTag</tagclass>
<bodycontent>EMPTY</bodycontent>
</tag>
</taglib>
JSP File:
<html>
<head>
<%@ taglib uri="csajsp-taglib.tld" prefix="csajsp" %>
<title><csajsp:example /><title>
</head>
<body>
<h1><csajsp:example /></h1>
<csajsp:example />
</body>
</html>
I put the JSP and TLD file in the same directory as the other JSP files go.And for the Tag class file I put that where other servlet classes are.But when I run the JSP file I get only a blank page.
I do not know why.
Can anyone help?I would appreciate any help.
 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ramesh,
I tested your code. It works fine.
Write the enclosing tag for 'title' as follow and you will see :
<title><csajsp:example /><</title>
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the JSP forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried basic debugging techniques?
Are there any compilation errors? Is there anything in the log files? What shows up in the HTML that is sent to the browser?
bear
 
Ramesh Bandaru
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to all.It worked.I just changed the </title> tag which was a typo.
Thanks to Engin in particular.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!