Hi everybody, I have a little question regarding the <type> element(subelement of <attribute> in a .tld file. I was wondering what was it used for? I wrote a tag handler that takes an attribute, so in my tag handler class I have something like this: note the type of the attribute is int
In my .tld file I have something like this:
and finally, in my .jsp page I have this code that works fine:
At this point everything is normal(to my understanding of course!). I tried to add a <type> element in the .tld file, specifing String as the type for the element like this:
Here I thought the container would try to convert my int variable to a string which would cause a translation time error, but it works fine. I also tried a couple of different variants like changing the type of the variable used in the jsp expression to String and putting a type of int for the element in the tld file expecting the container to convert the string variable to int, but no... The container takes the variable that is used in the jsp expression and passes it as a parameter to MyIterationTag.setIterations(int). The <type> element seems to be completelly useless! Anyway if someone understands this I would really apreciate the help Thanks in advance Dominic
Some JSP containers (such as Tomcat) are more lenient than others and often don't take into account the values defined within deployment descriptors. For example, trying changing the body-content of a tag to anything you like! The type element is just used to give the container a helping hand in determining what the type of the attribute is. Also, some containers may use it to actually restrict the values that can be specified for an attribute, and hence provide some rudimentary validation for you. In reality, this is one of those elements in the TLD file that is rarely used... Simon [ January 02, 2003: Message edited by: Simon Brown ]
Joined: Dec 13, 2002
Thanks for the explanation. I'am indeed using tomcat.