Solved

facing a problem while creating custom tag

Posted on 2009-07-09
4
291 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
FizzBuzz challenge 9 73
nested class vs inner class 5 47
for loop with Set 4 46
factorial example challenge 10 62
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now