This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes custom tag not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "custom tag not working " Watch "custom tag not working " New topic
Author

custom tag not working

taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
Hi,
i am just trying a simple example of a custom tag. but it does not run and gives root cause as INVALID PUBLIC ID- ....
can anybody help me to learn this properly
heres my web.xml and the error---
web.xml


B]Tomcat's response[/B]


Thanks
Taash


Cheers<p>Taash<br />SCJP2
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
hi
i got that error,my tld file had a different public definition, so i have corrected that but i still can't work this out as now Tomcat has proceded to say that
tlibversion needs to be decleared

heres the error

and my tld file

someody please enlighten me about this

thanks
taash
umar hathab
Ranch Hand

Joined: Aug 20, 2001
Posts: 52
Hi friends,
can u post me the jsp code ? I want to see how u r referring the taglib...
Since your taglib-uri is /WEB-INF/classes/js ,
you should have
<%@ taglib uri="/WEB-INF/classes/js" prefix="something" %>
and yr JavaScriptExTag.tld should be under /WEB-INF/

Hope this helps ..
A.Umar


Sun Certified Java Programmer for Java 2.0 (93%) <p>----Winners always make the learning a habit
sim sim
Ranch Hand

Joined: Jun 05, 2002
Posts: 55
HI taash,
Try this in your tld.
<?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" >

Hope this works.
Regards,
Sim Sim.
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
...and if you're using Tomcat 4, you can use the newer JSP 1.2 DTD (although some of the element names have changed) :

Simon
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
hi
Thanks to Simon and sim sim the xml problem is solved now though it has a path problem
Umar my jsp file has the same code but have a look
i m posting my JavaScript_Tag.jsp file
please help me correct the issues here
JavaScript_Tag.jsp

Thanks
Taash
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
hi
just in case
this is the hierarchy for my files
/WEB-INF/web.xml
/WEB-INF/JavaScriptExTag.tld
/WEB-INF/classes/JavaScriptExTag.java
/WEB-INF/classes/JavaScriptEx.java
/jsp/JavaScript_Tag.jsp

and a part of the root cause for error


Thanks
Taash
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
You'll need to put your tag handler class in a package, and then modify the TLD file appropriately. For example:
<tag-class>myPackage.JavaScriptExTag</tag-class>
(notice also that there is no leading / character)
Cheers
Simon
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
hi Simon,
i tried changing the hierarchy
so now it looks like this
this is the hierarchy for my files
/WEB-INF/web.xml
/WEB-INF/JavaScriptExTag.tld
/WEB-INF/classes/sunskriti/JavaScriptExTag.java
/WEB-INF/classes/sunskriti/JavaScriptEx.java
/jsp/JavaScript_Tag.jsp
and in my tld file
i modified it by putting it into a package called sunskriti

i also modified both my java files and added package statements but still am not getting result


Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Have you placed the compiled classes under /WEB-INF/classes too? That is :
/WEB-INF/classes/sunskriti/JavaScriptExTag.class
/WEB-INF/classes/sunskriti/JavaScriptEx.class
Simon
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
hi Simon
thanks for reminding me i nearly forgot that i had to compile these classes, silly of me any ways i did that but the class JavaScriptExTag really doesn't compile. it gives me many error
this is the code

it actaully doesn't recognise the Jsp Exceptions. wonder why?? i think we have imported the proper classes
is this Exception custom made in the wrox package?
Thanks again for all the help
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
If you're using Tomcat 4, you need to put the servlet.jar file (from TOMCAT_HOME/common/lib) in your CLASSPATH.
HTH
Simon
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
it is there Simon
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
hey
what do i do now, actaully trying examples takes a lot of time and i have my exams soon


maybe i should try them after my exams???
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
hey
what do i do now, actaully trying examples takes a lot of time and i have my exams soon


maybe i should try them after my exams???
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
Hi
But then if i quit i wouldn't learn so somebody please help me out here

thanks
sim sim
Ranch Hand

Joined: Jun 05, 2002
Posts: 55
Hi Taash,
I suggest you check your classpath once again, I have tried to compile your code and I got only one exception, cannot find,
JavaScriptEx JS = new JavaScriptEx();
I have commented the following lines
//JavaScriptEx JS = new JavaScriptEx();
//ls_alert=JS.alert(ls_message.trim());
and it compiled in a jiffy.
Pl check ur classpath for
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
Regards,
Sim Sim
amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231
Hi Taash,
Please compile JavaScriptEx.java first and include that into ur classpath as well. Then compile JavaScriptExTag.java
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
Hi
sim sim
I already have tools.jar in my classpath? Do i need to put jasper.jar too? as i have about 11 errors when i try to compile JavaScriptExTag.java and mostly regarding JspException and the other stuff.
this is a part of it

amit
i have already complied JavaScriptEx.java before doing this and both of these files are in the same directory.. but i am still not getting through this code
thanks
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
hi sim sim
i have my classpath set to this
where C:\jakarta-tomcat-4.0\webapps\ROOT\WEB-INF\classes\sunskriti

please let me know if i can do anything to aorrect it and incorporate things as u mentioned earlier. with this path it gives me the 11 errors
thanks
taash mg
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
hi sim sim
why actually am i getting 11 - 12 errors while u r getting less which means i m missing something. Something is not properly configured. please help
thanks
 
Don't get me started about those stupid light bulbs.
 
subject: custom tag not working
 
Similar Threads
Do Not Understand "/tags/struts-logic" Not Found
Exception while including taglibs(apache.org.xtags) in the JSP?
Unable to compile class for JSP error
TLD and Deployment Descriptor not Working
TLD and Deployment Descriptor not Working