Calling methods with parameters using JSTL

I was quite annoyed by the fact that you can’t just call a method with certain parameters using JSTL. Lucky me, google gave me a result where I could see how this is done (using JSP 2.0).

The thing is, you need to create a static method with the required parameters and then you need to define a TLD to be able to call the function. This process can probably be simplified by using a tool like XDoclet so your TLD is generated automatically, but I didn’t look into that, yet.

Another way to do it is described by Lucas Jellema on the AMIS blog. But I don’t call this a real solution, just a very dirty hack. I respect him for his posts on Oracle, but I don’t like this solution at all.

1 thought on “Calling methods with parameters using JSTL

  1. Jasper

    What’s wrong with creating a custom tag with attributes which you can use for the parameters? It’s powerful, it’ll result in more readable JSP and you should end up with a nice tag library JAR file which you can easily reuse.

    Reply

Leave a Reply to Jasper Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>