This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Any ideas on how I can pass array (String ...) in a taglib function in JSP?
If variable arguments where supported you would have to define the function in the TLD like this:
but that gives the following error:
The class java.lang.String... specified in the method signature in TLD for the function formTags:testFunction cannot be found.
It is expecting a fully qualified class name as parameter.
The proof can actually be found in the jsp2.0 specs:
JSP.C.1XML Schema for TLD, JSP 2.0 <xsd:element name="function-signature" type="j2ee:string">
Provides the signature, of the static Java method that is
to be used to implement the function. The syntax of the
function-signature element is as follows:
FunctionSignature ::= ReturnType S MethodName S? '(' S? Parameters? S? ')'
ReturnType ::= Type
MethodName ::= Identifier
Parameters ::= Parameter | ( Parameter S? ',' S? Parameters )
Parameter ::= Type
* Type is a basic type or a fully qualified Java class name (including package name), as per the 'Type' production in the Java Language Specification