Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JSP taglib: Unable to find setter method for attribute

136 views
Skip to first unread message

kaeli

unread,
Jan 5, 2004, 11:18:27 AM1/5/04
to

Okay, I can't get what's wrong with my code. This is my first try at a
taglib beyond the helloWorld example at orionserver.com (which worked).

Note that I already checked everything that I could find via Google,
including case of names, name conflict with parent class, putting in
getters, and unique signatures.

The compiler throws the exception "Unable to find setter method for
attribute" at setClosed. The other setters work fine.

Here is a sample of the setters/getters. The String one works. The
boolean one does not. (Am I not allowed to use boolean or something?)

private String perms=null;
private boolean closed=false;

public void setPerms(String perms)
{
this.perms = perms;
}
public String getPerms()
{
return this.perms;
}
public void setClosed(boolean closed)
{
this.closed = closed;
}
public boolean getClosed()
{
return this.closed;
}

The JSP code:
<my_taglib:theTextbox
perms="write"
closed="false"
/>

Any ideas?

Full error:
[05/Jan/2004:10:10:32] info ( 8100): JSP: JSP1x compiler threw exception
org.apache.jasper.JasperException: Unable to find setter method for
attribute: closed
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at javax.servlet.ServletException.<init>
(ServletException.java:107)
at org.apache.jasper.JasperException.<init>
(JasperException.java:73)
at org.apache.jasper.compiler.TagBeginGenerator.generateSetters
(Compiled Code)
at
org.apache.jasper.compiler.TagBeginGenerator.generateServiceMethodStatem
ents(TagBeginGenerator.java:210)
at org.apache.jasper.compiler.TagBeginGenerator.generate
(TagBeginGenerator.java:279)
at org.apache.jasper.compiler.JspParseEventListener
$GeneratorWrapper.generate(Compiled Code)
at org.apache.jasper.compiler.JspParseEventListener.generateAll
(Compiled Code)
at
org.apache.jasper.compiler.JspParseEventListener.endPageProcessing
(JspParseEventListener.java:180)
at org.apache.jasper.compiler.Compiler.compile(Compiled Code)
at com.netscape.server.http.servlet.NSServletEntity.load
(NSServletEntity.java:230)
at com.netscape.server.http.servlet.NSServletEntity.update
(NSServletEntity.java:149)
at com.netscape.server.http.servlet.NSServletRunner.Service
(NSServletRunner.java:469)

--
--
~kaeli~
When a clock is hungry, it goes back four seconds.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Sudsy

unread,
Jan 5, 2004, 11:33:55 AM1/5/04
to
kaeli wrote:
<snip>

> public void setClosed(boolean closed)
> {
> this.closed = closed;
> }
> public boolean getClosed()
> {
> return this.closed;
> }

Not permitted. You have to use String objects. Rewrite as follows:

public void setClosed( String closed ) {
this.closed = Boolean.getBoolean( closed );
}

public String getClosed() {
return( new Boolean( closed ).toString() );
}

kaeli

unread,
Jan 5, 2004, 11:36:42 AM1/5/04
to
In article <MPG.1a634a535...@nntp.lucent.com>,
tiny...@NOSPAM.comcast.net enlightened us with...

>
> Okay, I can't get what's wrong with my code. This is my first try at a
> taglib beyond the helloWorld example at orionserver.com (which worked).
>

Note: this error fixed. I'm an idiot and didn't recompile the code after
adding the getters.

full tag
<my_taglib:myTextbox


perms="write"
closed="false"
/>

However, I now have a new error. When I quote the attribute, I get an
error that it expects a boolean. When I don't quote it, I get an error
that attribute values should be quoted.
How do I resolve this?

If I quote it, I get this error.
(closed="false")

Incompatible type for method. Can't convert java.lang.String to boolean.
_jspx_th_my_taglib_myTextbox_0.setClosed("false");

If I don't quote it, I get
(closed=false)

[05/Jan/2004:10:29:16] info (14716): JSP: JSP1x compiler threw exception
org.apache.jasper.compiler.ParseException: /pages/test2.jsp(11,8)
Attribute value should be quoted

I'm confused.

--
--
~kaeli~
If that phone was up your a$$, maybe you could drive a
little better!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Sudsy

unread,
Jan 5, 2004, 11:39:50 AM1/5/04
to
kaeli wrote:
<snip>

> Incompatible type for method. Can't convert java.lang.String to boolean.
> _jspx_th_my_taglib_myTextbox_0.setClosed("false");

Please see my previous reply. Note the text of the error: "Can't convert
java.lang.String to boolean". Just what I was trying to convey earlier.

kaeli

unread,
Jan 5, 2004, 1:28:43 PM1/5/04
to
In article <3FF991F3...@hotmail.com>, bitbu...@hotmail.com
enlightened us with...

> kaeli wrote:
> <snip>
> > public void setClosed(boolean closed)
> > {
> > this.closed = closed;
> > }
> > public boolean getClosed()
> > {
> > return this.closed;
> > }
>
> Not permitted. You have to use String objects. Rewrite as follows:
>

I was beginning to think that was the case, but I am having a really
hard time finding good documentation for custom taglibs (read: not API
docs, but something readable for beginners) for someone not using
Tomcat.

Thanks!

Sudsy

unread,
Jan 5, 2004, 2:15:44 PM1/5/04
to
kaeli wrote:
<snip>

> I was beginning to think that was the case, but I am having a really
> hard time finding good documentation for custom taglibs (read: not API
> docs, but something readable for beginners) for someone not using
> Tomcat.
>
> Thanks!

You're welcome. I highly recommend "Advanced JavaServer Pages" by David
M. Geary (ISBN 0-13-030704-1).

0 new messages