Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6734651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:54:51+00:00 2026-05-26T10:54:51+00:00

I want to create a custom tag library but in the handler class I

  • 0

I want to create a custom tag library but in the handler class I would like to have integer attributes.

In the tld file I have the following code:

<tag>
        <name>circle</name>
        <tag-class>draw.Circle</tag-class>
        <body-content>jsp</body-content>
        <attribute>
            <name>x</name>
            <required>true</required>
        </attribute>
</tag>

there are also other integer attributes, but this example is relevant for the others.

The handler class, for the moment looks this way:

public class Circle extends TagSupport{
    private Integer x;

    public Integer getX() {
        return x;
    }
    public void setX(String x) {
        this.x = Integer.parseInt(x);
        System.out.println("Set x");
    }
}

I haven’t specified the attribute type in the tld file, and default it should be String. Though I get an error like this:

Unable to find setter method for attribute: x

I have also tried modifying the attribute type to: <type>java.lang.Integer</type> and the setter method to:

public void setX(int x) {
    } 

And I get the same error.

How should I define the attribute in the tld file and the setter in the handler class so that I don’t get the setter error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:54:52+00:00Added an answer on May 26, 2026 at 10:54 am

    JSP custom tags use the JavaBeans technology, which has standard conventions (here’s a small JavaBeans tutorial that captures the main aspects).

    A “bean property” (see PropertyDescriptor) consists of a getter and / or a setter method of the same type (return type of the getter must match single param type of the setter), otherwise they are not mapped to the same bean property (I’m guessing the first method in the class “wins”). So your Integer getter / String setter approach can’t work, as the String setter will not be detected as belonging to the Integer property).

    Set the parameter type of the setter method to Integer and it will work, the conversion will be applied automatically, JavaBeans has built-in support for value conversion through the PropertyEditor interface (implementations for at least all primitive value types exist, and through auto-unboxing, Integer can be considered primitive).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a custom control in C#. But every time I have
I want to create custom tag, but i get XML parsing error on JSPVersion
I want to create a custom tag which would mark a field readonly on
In C# if I want to create a Custom Event you do something like
I'm currently studying WordPress and want to create a custom Post Type and have
I want to create a custom MSBuild task that changes my .cs files before
I want to create a custom set that will automatically convert objects into a
I want to create a custom property on one of my entities mapped from
I want to create a custom list in Flex for an interface prototype. The
I want to create a custom alert view within my iOS application. For example,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.