Search code examples
javajstlmethod-call

How to call java method in JSTL?


This might be duplicate question.

I just want to call method which is not getter or setter method eg. makeCall(someObj,"stringvalue") of xyz class.

Java Class

Class XYZ{

    public String makeCall(Object objValue, String stringValue){

    //some logic here

    }
}

JSTL

<jsp:userBean id="xyz" class="com.XYZ"/>
${xyz.makeCall("hello","Friend")}

Solution

  • For resolve this we need create your own tag. (in .tld file)

    and need to write one java class for this tag.

    After this you can call method within that your own class and set result to pageCotext to retrive it on jsp.