Solved

facing a problem while creating custom tag

Posted on 2009-07-09
4
302 Views
Last Modified: 2013-11-24
Hi In the below example i want to use one custom tag, but i am facing one problem while i testing this application.
the error is like

"
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 5 in the jsp file: /index.jsp
Generated servlet error:
SimpleTagTest2 cannot be resolved to a type

An error occurred at line: 5 in the jsp file: /index.jsp
Generated servlet error:
SimpleTagTest2 cannot be resolved to a type


      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
"

and My JSP,tag handler class,tld mentioned in the code
u please verify the code and tell me where is the problem
MYJSP
 
<%@ taglib prefix="myTags" uri="simpleTags" %>
<html>
<body>
Simple Tag 2:
<myTags:simple2>
 This is The Body
 </myTags:simple2>
</body>
</html>
----------------------------------------------------------------
MY TLD
----
<?xml version="1.0" encoding="ISO-8859-1" ?>
<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/web-jsptaglibrary_2_0.xsd" version="2.0">
 
<tlib-version>1.2</tlib-version>
<uri>simpleTags</uri>
<tag>
 <description>Hi I am Manually Generated Tag</description>
 <name>simple2</name>
 <tag-class>SimpleTagTest2</tag-class>
 <body-content>scriptless</body-content>
</tag>
</taglib>
-----------------------------------------------------------------
My TAGHANDLER CLASS
---
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.*;
public class SimpleTagTest2 extends SimpleTagSupport
{
	public void doTag()throws JspException,IOException
	{
		getJspBody().invoke(null);
	}
}

Open in new window

0
Comment
Question by:haneefnb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
mahome earned 500 total points
ID: 24820825
Did you check if SimpleTagTest2 gets compiled in WEB-INF/classes?
You can try using a package, don't forget to update you tld for that. Sometimes that helps.
0
 

Author Comment

by:haneefnb
ID: 24821146
ok. u please tell me what is the purpose of the doTag(),doStartTag(),doEndTag() in the Tag handler class
0
 
LVL 10

Expert Comment

by:mahome
ID: 24821270
Is the error gone? If yes, what did help?

For Tag Handler, look here: http://onjava.com/pub/a/onjava/2000/12/15/jsp_custom_tags.html
0
 

Author Closing Comment

by:haneefnb
ID: 31601957
Thanks...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question