• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom Tag and JRUN 3.1

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am trying to run a custom tag in JRUN.
I placed my jsp and dlt file in:
JRun\servers\default\default-app\
and I placed my class file in:
JRun\servers\default\default-app\WEB-INF\classes
my dlt file looks like this:
<?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.0</jspversion>
<shortname>advjhtp1</shortname>
<info>
A simple tag library for the examples
</info>
<tag>
<name>welcome</name>
<tagclass>
WelcomeTagHandler
</tagclass>
<bodycontent>empty</bodycontent>
<info>
Inserts content welcoming user to tag libraries
</info>
</tag>
</taglib>

my java file looks like this:
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class WelcomeTagHandler extends TagSupport{
//method called to begin tag processing
public int doStartTag() throws JspException{
//attempt tag processing
try{
//obtain jspWriter to output content
JspWriter out = pageContext.getOut();
//output content
out.print("Welcome to JSP Tag Libraries");
}
catch(IOException e){
throw new JspException(e.getMessage());
}
return SKIP_BODY;
}
}

and my jsp file looks like this:
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml-strict.dtd">
<%-- taglib directive --%>
<%@ taglib uri = "advjhtp1-taglib.tld" prefix = "advjhtp1" %>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Simple Custom Tag Example</title>
</head>
<body>
<p>The following text demonstrates a custom tag:</p>
<h1>
<advjhtp1:welcome />
</h1>
</body>
</html>

I get the following error when trying to run the jsp:
/customTagWelcome.jsp:
javax.servlet.ServletException: Parse Error in JSP page: The tag handler class '
WelcomeTagHandler
' for custom tag 'welcome' on line '16' could not be found.

I tried everything. i tried using a package, i tried placing the class file in every possible directory. but it just can't seem to find the class file for some reason.
does anyone know where exactly all the necessary files need to be in order to run properly?
Thank you
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I recall, your .tld (not dlt) file should go under WEB-INF somewhere since it is not supposed to be served by the web server. Furthermore, you need to insert a taglib section in the web.xml. That is what tells JRun how to find your taglib. Its all defined in the JSP API - you should download that from java.sun.com.
Bill
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic