This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Syntax of tld function-signature with varargs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Syntax of tld function-signature with varargs" Watch "Syntax of tld function-signature with varargs" New topic
Author

Syntax of tld function-signature with varargs

Max Rahder
Ranch Hand

Joined: Nov 06, 2000
Posts: 177
I'm trying to specify a function in a tld for a method whose argument is a varchar. What's the syntax?

My signature is,
public static String removeEnds(String string, String... prefixes) {

I'm not really sure what to try in the tld, although the obvious does not work:
<function-signature>java.lang.String removeEnds(java.lang.String, java.lang.String...)</function-signature>

When I tried this I got the following runtime error, so it obviously isn't recognizing that "String..." is special sytax, and not the name of a class.
org.apache.jasper.JasperException: The class java.lang.String... specified in the method signature in TLD for the function fn:removeEnds cannot be found. java.lang.String...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

I've never tried to do this, but as varargs syntax is just syntactic sugar for arrays, you might try using array notation instead. Please let us know what you discover.

P.S. Please use code tags, rather than bold, to post code fragments. Thanks.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Max Rahder
Ranch Hand

Joined: Nov 06, 2000
Posts: 177
Thanks for the idea, but that didn't work either. I can't figure it out. I switched the method to take a string and a delimiter -- the routine splits the string and processes the resulting array as before.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

I didn't mean to change the method... just how it was specified in the TLD.
Max Rahder
Ranch Hand

Joined: Nov 06, 2000
Posts: 177
No, I tried that first -- changed the signature in the tld to array. Then I tried passing in fn:split() on the items, etc. I tried several combinations, and finally waved the white flag and went with the solution above. Thanks for the help. :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Syntax of tld function-signature with varargs
 
Similar Threads
Passing array in an EL taglib function
Sample web.xml.. may be useful for SCWCD Ranchers
calling a bean function using jstl
EL function with parameter
fully qualified name in EL functions