3

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")}
Sachin J
  • 2,081
  • 12
  • 36
  • 50

3 Answers3

5

Simply create an object of the class using <jsp:useBean> and call the method using JavaServer Pages Standard Tag Library or Expression Language that is more easy to use and less error prone.

sample code:

<jsp:useBean id="test" class="com.x.y.z.XYZ"/>

${test.methodXYZ(object,"myString")}

Read more about Implicit Objects that might help you.

Braj
  • 46,415
  • 5
  • 60
  • 76
2

Try with this:

<c:out value="${XYZbean.makeCall(someObjBean, 'value')}" />
Balduz
  • 3,560
  • 19
  • 35
1

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.

Sachin J
  • 2,081
  • 12
  • 36
  • 50