0

on a jsp file I have the following code that is used by the page to populate the DataBean java class with some data:

<jsp:useBean id="dataBean" scope="request" class="a.b.c.DataBean"/>

The DataBean.java has the method:

public static String getOverrideOption() {
    return OVERRIDE_OPTION;
}

I want to use that method on the page to enable/disable a checkbox depending on the return, this is the code on the jsp:

<tr>
    <th class="light">Use old method:</th>
    <td colspan="2">
        <span class="radiobuttons">
            <input type="checkbox" alt="Old Method" name="oldMethod"
                ${dataBean.oldMethod ? "checked" : ""} />
        </span>
    </td>
</tr>

I have tried creating a script to try and fetch the data, assign it to a variable or string and then make the string as enabled/disabled on the checkbox but so far no success.

I am not very familiar with jsp so I am trying to figure it out but no luck so far, any help would be much appreciated.

eSp
  • 45
  • 5

1 Answers1

1

Edited:

Try removing static modifier,

${'your string' == dataBean.getOverrideOption() ? "checked" : ""}
  • 1
    Won't work, it is not possible to access static variables/methods from JSP EL. There are some workarounds, though, see http://stackoverflow.com/questions/3732608/how-to-reference-constants-in-el – Jozef Chocholacek Jun 29 '15 at 11:00
  • I can make the method not static without impact to the application code, which I will do in a bit and try it again – eSp Jun 29 '15 at 11:07