Struts and comparison of multiple values


Web tier: servlets, JSP, Web frameworks: Struts and comparison of multiple values

  1. Struts and comparison of multiple values (2 messages)


    I have two values I would like to compare to a bean value. How can I impelement this with the struts tag library in stead of inline JSP? Below is an excerpt of my code:
        <bean:define id="selectionBean" name="selectionBean" type="SelectionBean" />
        if(selectionBean.getActiveItem().equals("duplicates") || selectionBean.getActiveItem().equals("noDuplicates")) {
          // Some logic here

    Can this if-test be replaces by Struts tags? The logic:equal tag can, as far as I know, only compare one value in the value-attribute.

    Any input will be appreciated!

  2. Hi Kari,

    you can also use the jstl-TagLibrary like this:<br/>

    test="${selectionBean.activeItem == 'duplicates' || selectionBean.activeItem == 'noDuplicates' }"><br/>
      // Some logic here<br/>

    <br>In your JSP import define a taglib:<br/>
    <tt><%@ taglib prefix="c" uri="" %></tt>

    You also need the libraries <code>standard.jar</code> and <code>jstl.jar</code>. <br/>
    Look on the following page for download:<br/><br/>

  3. Hi Bodo,

    Of course, why diden't I think of that? Thank you very much!

    Kari =)