aspose file tools
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
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply 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: 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
    
  13

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
    
  13

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Is it possible to access instance methods that take arguments in EL for JSP 2.1?
 
Similar Threads
c:if syntax error
call bean's funtion in jsp
JSF 1.1 vs. JSF 1.2
Need some advice on converting scriptlet code to jstl
EL functions information