Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Error using taghandler, why does it not work?

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on Tag-Handlers with JSP getting some errors:
/* This is a taghandler class
*/
package simpletag;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class SimpleTag extends javax.servlet.jsp.tagext.TagSupport
{
public int doStartTag() throws JspException
{
try
{
pageContext.getOut().print("Welcome to my Web site.");
}
catch (Exception e)
{
throw new JspTagException(e.getMessage() );
}
return SKIP_BODY;
}
}
Here is a very simple "usertag.jsp" which is located at:
D:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\jsp\Whitehead\chap10
<html>
<head>
<title> Tag example</title>
</head>
<body>
<%@ taglib uri=""http://www.maran.com/taglib" %>
<myTags:simpletag.simpleTag></myTags:simpletag.simpleTag>
</body>
</html>
I have writtentag library descriptor called "taglib.tld" this is located in the following directory:
D:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\WEB-INF\classes\simpletag
Is this correct? the book I am using does not mention where to put my "tablib.tld"
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTDT JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.1</tlibversion>
<jspversion>1.1</jspversion>
<shortname>MyFirstTag</shortname>
<info>My first tag library descriptor file</info>
<tag>
<name>SimpleTag</name>
<tagclass>simpletag.SimpleTag</tagclass>
</tag>
</taglib>
The book mentions I need to add some code to a class called "web.xml"
I have decided to edit the web.xml file located at D:\tomcat\jakarta-tomcat-3.3.1\webapps\ROOT\WEB-INF
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<taglib>
<taglib-uri>
http://www.maran.com/taglib
<taglib-uri>
<taglib-location>
/WEB-INF/classes/simpletag/taglib.tld
</taglib-location>
</taglib>
</web-app>

<taglib>
<taglib-uri>
http://www.maran.com/taglib
<taglib-uri>
<taglib-location>
/WEB-INF/classes/simpletag/taglib.tld
</taglib-location>
</taglib>
Here is the error:
Error: 500
Location: /myJSPs/jsp/Whitehead/chap10/usetag.jsp
Internal Servlet Error:
org.apache.jasper.compiler.ParseException: D:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\jsp\Whitehead\chap10\usetag.jsp(5,23) Attribute http: has no value
at org.apache.jasper.compiler.JspReader.parseAttributeValue(JspReader.java:528)
at org.apache.jasper.compiler.JspReader.parseTagAttributes(JspReader.java:644)
at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:192)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1077)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1042)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:209)
at org.apache.tomcat.facade.JasperLiaison.jsp2java(JspInterceptor.java:790)
at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:731)
at org.apache.tomcat.facade.JspInterceptor.requestMap(JspInterceptor.java:506)
at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:968)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:875)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:484)
Here is the usetag.jsp
<html>
<head>
<title> Tag example</title>
</head>
<body>
<%@ taglib uri=""http://www.maran.com/taglib" %>
<myTags:simpletag.simpleTag></myTags:simpletag.simpleTag>
</body>
</html>
 
Saloon Keeper
Posts: 24332
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The taglib tld files are normally placed somewhere under the webapps WEB-INF directory tree where they will be hidden from unfriendly eyes.
Here's a taglib reference from a JSP:

And here's the corresponding clause from the web.xml file that causes the URI to matchup to the actual taglib location (which for this example is the same as the URI):
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic