We help IT Professionals succeed at work.

call another function from jsp using jstl tag?

dkim18 asked

I have this domain object. Which I am calling from a jsp page.
It is a boolean and  When I display it, I would like to convert it to a string so it prints yes or no.
Is there a way to call, getTagIDText() instead?

 <tr><td>Tag ID</td><td><c:out value="${myItems.tagID}" /></td></tr>  <=== this return 1 or 0

boolean tagID;

public boolean getTagID() {
        return tagID;

    public void setTagID(boolean tagID) {
        this.tagID = tagID;
    public String getTagIDText(){
        if (tagID){
            return "Yes";
        } else {
            return "No";

Open in new window

Watch Question

I think you can use

 <tr><td>Tag ID</td><td><c:out value="${myItems.tagIDText}" /></td></tr>  <=== this return 1 or 0

This may give you an error because you don't have a setTagIDText.  In that case, the quick answer would be to just make a dummy one.


I used the EL instead.