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

cannot find the declaration of element taglib

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

but i am getting this error:cvc-elt.1: cannot find the declaration of element 'taglib'


Where did you get this error ?
 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting this error in the eclipse.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I asked "Where did you get this error ?", I was asking which file.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, put a web.xml looking like this under WEB-INF :
 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
He's giving us the slip! Quick! Grab this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic