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

Unable to compile class for JSP (Using custom tag)

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

i am trying to display header using custom tag, my tld file is found in the folder WEB-INF/customTag.tld and is defined as follows:



My java class is found in the package com.pask and is defined as follows:


My Jsp is defined as follows:


However my i run the above jsp on apcahe tomcat 6 to test i get the following error message:



Any idea how i can resolve this issue please?

Thanks.
 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think there might be a problem with your tld file.
Try replacing this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>

with this:

<?xml version="1.0" encoding="UTF-8" ?>
<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 http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
 
ashley Jug
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

i have changed my tld file as follows:


But will have the same error message:

Any suggestion please?
Thanks again.
 
Ranch Hand
Posts: 81
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats strange...

the problems you get are normal, IF you should use the

public CustomTag extends TagSupport {}

it uses the doEndTag() and doStartTag(), so you must use them

but you are using the

public class CustomTag extends SimpleTagSupport

...im not familiar with the SimpleTagSupport, but i see that your doTag() should be enough...

The way i see it, you get errors like it would come from Tagsupport, not from SimpleTagSupport...

of course...it could be something in your tld not being right...
 
Piyush Joshi
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apart from the above mentioned tld changes also check that you are using correct version of jars. SimpleTagSupport was added in JSP-2.0. If you are using an IDE then check the default settings.
 
ashley Jug
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

since the simple SimpleTagSupport is not working and not much resources available, i have tried the to use TagSupport instead.

However i am getting a null pointer exception as follows:



My tld file is in WEB-INF folder:


My java class is found below:


My jsp file is found in WebContent folder as follows:


Any suggestion why i am getting the null pointer exception?

Thanks



 
Piyush Joshi
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ashley Jug wrote:Hello,

since the simple SimpleTagSupport is not working and not much resources available.


See the Similar Problem and its solution. Also This
May be same is the case here. BTW I tested your Simple tag code and its working fine. So I guess problem is not in code. As suggested in the above links please check your JEE version, classpath etc..

and for your classic tag: open the servlet code generated by the test.jsp page named test_jsp.java (you can find it in the "work\Catalina\localhost\" folder in Tomcat installation directory) and see the line 30. This is the line pointed by the stack trace:
org.apache.jsp.test_jsp._jspInit(test_jsp.java:30)
See what's wrong in that line.
 
ashley Jug
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

how can i check my j2ee version in eclipse?

Thanks a lot for the quick response.
 
Piyush Joshi
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right click on your project node in Package Explorer. Go to Properties->>Project Facets.
Check the Dynamic Web Module version number in Project Facets list.
It must be 2.4 or above for Simple tag support to work.

Also try this : Which Version Am I Running On
 
ashley Jug
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

just done something and its working fine now.

In case someone else have this problem again:

In my lib folder there was the following jar:

jsp api

i have deleted it and instead copied this jar:
j2ee-1.4.jar

It working fine now.

Thanks again for all the help and advice, and Mr Piyush i know you stated earlier that i was using the wrong jar version, you were right and thanks again.
 
Piyush Joshi
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
great.
I am happy that finally problem was solved
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eek! As posted elsewhere in other topic, you should never have the jee jars in your lib folder! The container supplies those and putting them in lib causes no end of weird problems!
 
Your mother is a hamster and your father smells of tiny ads!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic