wood burning stoves 2.0*
The moose likes JSP and the fly likes Unable to compile class for JSP (Using custom tag) 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 "Unable to compile class for JSP (Using custom tag)" Watch "Unable to compile class for JSP (Using custom tag)" New topic
Author

Unable to compile class for JSP (Using custom tag)

ashley Jug
Ranch Hand

Joined: Sep 02, 2011
Posts: 60
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.
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

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">


Piyush
ashley Jug
Ranch Hand

Joined: Sep 02, 2011
Posts: 60
Hello,

i have changed my tld file as follows:


But will have the same error message:

Any suggestion please?
Thanks again.
olivier dutranoit
Ranch Hand

Joined: Aug 20, 2011
Posts: 81

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

Joined: Jun 10, 2011
Posts: 207

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

Joined: Sep 02, 2011
Posts: 60
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

Joined: Jun 10, 2011
Posts: 207

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

Joined: Sep 02, 2011
Posts: 60
Hello,

how can i check my j2ee version in eclipse?

Thanks a lot for the quick response.
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

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

Joined: Sep 02, 2011
Posts: 60
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

Joined: Jun 10, 2011
Posts: 207

great.
I am happy that finally problem was solved
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

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!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to compile class for JSP (Using custom tag)
 
Similar Threads
AdvisorTagHandler unable to compile
Problem with JBOSS Server
Help - problem with a fresh install of tomcat and JSP - SOLVED
Problems in my code
Help - problem with a fresh install of tomcat and JSP