| 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: 77
|
|
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: 77
|
|
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: 56233
|
|
|
Are you sure that the container supports JSP 2.1?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Rob Dennett
Ranch Hand
Joined: Dec 07, 2010
Posts: 77
|
|
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: 56233
|
|
|
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.
|
 |
 |
|
|
subject: Is it possible to access instance methods that take arguments in EL for JSP 2.1?
|
|
|