| Author |
cannot find the declaration of element taglib
|
sudhakar karnati
Ranch Hand
Joined: May 03, 2007
Posts: 93
|
|
Hi All, I am using eclipse to practice custom tag examples given in the HFSJ in eclipse i created new project as apache tomcat project and in WEB-INF folder i created a file named simple.tld with the following content <?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>marginally better use of a custom tag</description> <name>simple1</name> <tag-class>foo.SimpleTagTest1</tag-class> <body-content>empty</body-content> </tag> </taglib> and usetag.jsp with the following content package foo; import java.io.IOException; import javax.servlet.jsp.tagext.SimpleTagSupport; import javax.servlet.jsp.JspException; public class SimpleTagTest1 extends SimpleTagSupport { public void doTag() throws JspException, IOException { getJspContext().getOut().print("This is the lamest use of a custom tag"); } } and SimpleTagTest1.java is placed in foo pacakge but i am getting this error: cvc-elt.1: cannot find the declaration of element 'taglib' Can any body suggest me what is wrong? Thanks & Regards, Sudhakar Karnati [ April 17, 2008: Message edited by: sudhakar karnati ]
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14670
|
|
but i am getting this error:cvc-elt.1: cannot find the declaration of element 'taglib'
Where did you get this error ?
|
[My Blog]
All roads lead to JavaRanch
|
 |
sudhakar karnati
Ranch Hand
Joined: May 03, 2007
Posts: 93
|
|
|
I am getting this error in the eclipse.
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
Try... xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" ... as your schema location in the TLD. This is really how it should be but I don't think Eclipse was so picky about it in the past. [ April 17, 2008: Message edited by: Marc Peabody ]
|
A good workman is known by his tools.
|
 |
sudhakar karnati
Ranch Hand
Joined: May 03, 2007
Posts: 93
|
|
Marc, Do you want me to remove version="2.0" attribute in the taglib.. and i did not include any web.xml in the project because there is no such thing explained in the HFSJ about web.xml in the Custom tag development chapter till the page i read. I tried by removing verion attribute it is still showing the same error. Please help some body.. Thanks & Regards, Sudhakar Karnati [ April 17, 2008: Message edited by: sudhakar karnati ]
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
Originally posted by sudhakar karnati: I tried by removing verion attribute it is still showing the same error.
Ummm... but that's not what I said to try. You came up with that. Are we communicating or are we both talking to ourselves here? Did you try what I recommended?
|
 |
sudhakar karnati
Ranch Hand
Joined: May 03, 2007
Posts: 93
|
|
I have changed my simple.tld as above and now it is showing 41 errors: I did not create any web.xml file,if it should be created how it should be because in HFSJ that is not explained how to configure web.cml for tld(till the page i read).. Please help me Thanks & Regards, Sudhakar Karnati
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14670
|
|
|
When I asked "Where did you get this error ?", I was asking which file.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14670
|
|
This works: The tag The TLD (under WEB-INF) The JSP If you still have errors, this thread will be moved to the Eclipse forum.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14670
|
|
Also, put a web.xml looking like this under WEB-INF :
|
 |
sudhakar karnati
Ranch Hand
Joined: May 03, 2007
Posts: 93
|
|
Thanks very much Christophe Verre. Thanks very much for posting code also.. The thing i have learnt from this issue is for learners Netbeans is better option than Eclipse... I experienced difficulty in using eclipse because we have to add plug-ins compared to Netbeans.. But i remember one thing in the preface page or somewhere in the HFSJ book it is given that if we are really preparing SCWCD we should not use any IDE.. but i have seen a topic which is totally about which IDE we should use.. even i am using IDE for practicing examples because it makes our life easy.. Thanks & Regards, Sudhakar Karnati [ April 18, 2008: Message edited by: sudhakar karnati ]
|
 |
 |
|
|
subject: cannot find the declaration of element taglib
|
|
|