wood burning stoves 2.0*
The moose likes JSP and the fly likes Passing variable name to java method with JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing variable name to java method with JSTL" Watch "Passing variable name to java method with JSTL" New topic
Author

Passing variable name to java method with JSTL

Riccardo Panaia
Greenhorn

Joined: Dec 31, 2003
Posts: 2
Hello All, my first time posting here. I've done some research on this topic and so far have come up empty. What I am trying to do is call a java method and pass a parameter string using JSTL. Here is a sample of the code I am using:
<c:when test='${holding.product.validity["lineOfBusiness"] == "1"}'> This code compiles but throws this error when hit:
An error occurred while evaluating custom action attribute "test" with value "${holding.product.validity["lineOfBusiness"] == "1" && holding.product.lineOfBusiness != null}":
Unable to find a value for "validity" in object of class "com.mm.dts.paar.data.PAARProduct" using operator "." (null)
Now I am fairly new to the whole java/jsp/jstl realm, but my first question is it possible to call a java method and pass in a parameter using jstl core tags? If this it true, then my next question would be is my syntax messed up that's causing it to fail? Thanks in advance for any suggestions/comments. Thanks, Rick.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

To my knowledge, no. (Caveat, I recall reading something about JSP 2 being able to do something along these lines, but I haven't had a chance to play around with it yet -- you know, busy getting product out the door and all).
However, in your example, the EL is expecting 'validity' to be a property of the 'product' bean. If 'validity' is a method (as I suspect from your post), the EL will not call it. (Rather it is looking for method getValidity()).
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Riccardo Panaia
Greenhorn

Joined: Dec 31, 2003
Posts: 2
Thanks for the input Bear, I was afraid of that. Back to rewriting my code. Happy New Year!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing variable name to java method with JSTL
 
Similar Threads
Error about JDBC in O'Reilly's Enterprise Java in a Nutshell?
call java funtion in jstl
Using Scriptlets in Custon Tags
Problems creating a JDBC driver / JNDI connection
How to get results into same jsp