wood burning stoves 2.0*
The moose likes JSP and the fly likes Is it possible to access instance methods that take arguments in EL for JSP 2.1? 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 "Is it possible to access instance methods that take arguments in EL for JSP 2.1?" Watch "Is it possible to access instance methods that take arguments in EL for JSP 2.1?" New topic
Author

Is it possible to access instance methods that take arguments in EL for JSP 2.1?

Rob Dennett
Ranch Hand

Joined: Dec 07, 2010
Posts: 79
I am trying to access a member function of an instance object in EL. Is this even possible? I had read on stackoverflow.com that this is a new feature of JSP 2.1. Is that accurate?

This is what latest version of Expression Language (from JSP 2.1) allows you to do. It can call methods (non-static functions):

${bean.doSomethingGreat('with arguments')}

(Original EL allowed you to call getters only, using ${bean.property} syntax).


Thanks,
Rob
Nitin Surana
Ranch Hand

Joined: Jan 21, 2011
Posts: 129

Yes! thats possible.
Rob Dennett
Ranch Hand

Joined: Dec 07, 2010
Posts: 79
Well, I tried it and got "The function theFunctionThatTakesArgumentsThatIAmTryingToCall must be used with a prefix when a default namespace is not specified" where the EL looked like ${theBeanThatHasTheFunction.theFunctionThatTakesArgumentsThatIAmTryingToCall(pageContext.request)}. Are there any obvious problems with this?

Thanks,
Rob
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Are you sure that the container supports JSP 2.1?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Dennett
Ranch Hand

Joined: Dec 07, 2010
Posts: 79
Were using Tomcat 6. As it happens, I used another solution, but I am still curious about this.

Rob
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Actually, I believe the original answer was wrong. Method invocation is added to JSP with 2.2, not 2.1. You'll need Tomcat 7 (I think -- haven't tried it yet) for JSP 2.2 support.
 
Don't get me started about those stupid light bulbs.
 
subject: Is it possible to access instance methods that take arguments in EL for JSP 2.1?
 
Similar Threads
JSF 1.1 vs. JSF 1.2
EL functions information
c:if syntax error
call bean's funtion in jsp
Need some advice on converting scriptlet code to jstl