This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
This is in some ways a hypothetical question, though I have run into some situations where I have needed to do this and I cannot find any documentation indicating it is possible.
I have a fairly basic JavaBean. I have no issues initializing it and getting/setting properties. What I cannot find any information on is how to call a plain old method in the bean from within a JSP page. By 'plain old method' I mean one that is not a getter or a setter.
Here is some sample code.
What I would like to do is something like this.
Where doSomethingCool() is a method defined in the bean.
I usually get around this by just creating a method called something like setDoSomethingCool(String ignoreMe), and then using setProperty to call the method.
Is it not possible to call a plain old method from within a JSP page?
If not, is there a reason?
P.S. You can call static methods by setting up an EL function, but not instance methods.
John Storta Jr.
Joined: Jul 26, 2009
I think I have not been using beans properly then. I will have to look into whether or not what I am actually trying to do can be accomplished with static methods or perhaps change my code within the accessor methods.
Or, take a step back and check that what you are doing is appropriate for a JSP. Many times, if you find yourself having trouble doing something, it's because it should have already been handled by the controller.