• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rob Dennett
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 129
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes! thats possible.
 
Rob Dennett
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that the container supports JSP 2.1?
 
Rob Dennett
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic