Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Problem with Struts JSP logic:equal tag code

Posted on 2004-08-10
4
3,571 Views
Last Modified: 2012-06-27
We are writing a new Struts (1.1) based web application.  One of the JSP's we are writing requires us to display a table of business check information.  A code snippet follows:

*****

    <tr>
        <td colspan="2" valign="top" nowrap>
        <table>
            <logic:iterate collection="<%=checks%>"
                   id="check"
         type="com.health.portal.vo.CheckSummaryVO"
         indexId="counter" >
                     <jsp:getProperty name="check" property="checkNumber" />
                    <jsp:getProperty name="check" property="checkDate" />
                    <jsp:getProperty name="check" property="checkVoidDate" />

                <logic:equal property="(counter.intValue()%3)" value="0">
                    </tr>
                    <tr>
                </logic:equal>
           
             </logic:iterate>      
         </table>
        </td>
    </tr>

*****
The problem I am having is with the logic:equal statement.  What I am trying to do is use the collection index (counter), perform a reminder operation on it, and after I have written 3 columns start a new table row.  The problem is I cannot seem to get the logic:equal statement formatted correctly.  I keep getting different JSP compile errors.  What is the correct way to write this?  Do I use property=, or name=, etc.  Or do I have to do something else entirely?

Thanks in advance!

Environment:
Java JDK v1.3.1_11
Tomcat v3.3a
Struts 1.1
On Windows XP Professional
0
Comment
Question by:mbeede
  • 2
4 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 11766463
I would use JSTL (which could be tricky as you have such an old version of Tomcat), or in native JSP code:

    <tr>
        <td colspan="2" valign="top" nowrap>
        <table>
            <logic:iterate collection="<%=checks%>"
                   id="check"
        type="com.health.portal.vo.CheckSummaryVO"
        indexId="counter" >
                   <jsp:getProperty name="check" property="checkNumber" />
                  <jsp:getProperty name="check" property="checkDate" />
                  <jsp:getProperty name="check" property="checkVoidDate" />

                <% if( ( counter.intValue() % 3 ) == 0 ) { %>
                    </tr>
                    <tr>
                <% } %>
           
             </logic:iterate>    
         </table>
        </td>
    </tr>
0
 

Author Comment

by:mbeede
ID: 11766568
I appreciate your quick response on this.  I got it working this way too.  However, can it be done using a logic:equal tag, or another kind of logic:? tag specifically?  Our project lead wants us to use tags as much as possible.  Example please!

Thanks again!
0
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 11766626
I don't think logic:equal accepts evaluations as parameters...

I don't think it does...maybe someone can prove me wrong (I hope so, as it will simplify loads of my code) ;-)

As I said, there are the JSTL tags, which have things like c:test (which I think you would need here), but I haven't really used them myself...And I'm not sure they will work with Tomcat3

I will have a search about tomorrow if no-one else has solved this for you,   I have to take the gf to the pub ;-)

Good luck with it!!

Tim

http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSTL.html
http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSTL5.html#74001
0
 
LVL 9

Expert Comment

by:nimaig
ID: 11769884
Tim is correct. <logic:equal> don't accepts evaluations as parameters.
If you need to use only struts tag you can do the following.

<tr>
        <td colspan="2" valign="top" nowrap>
        <table>
            <logic:iterate collection="<%=checks%>"
                   id="check"
        type="com.health.portal.vo.CheckSummaryVO"
        indexId="counter" >
                   <jsp:getProperty name="check" property="checkNumber" />
                  <jsp:getProperty name="check" property="checkDate" />
                  <jsp:getProperty name="check" property="checkVoidDate" />

                <bean:define id="myCondition" value="<%=String.valueOf(counter.intValue()%3)%>"/>
                <logic:equal name="myCondition" value="0">
                    </tr>
                    <tr>
                </logic:equal>
           
             </logic:iterate>    
         </table>
        </td>
    </tr>

 
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
some methods private some are not 8 217
Multiple Images Upload [JSP Web-application] 3 41
authenticate preemptively soap ui option 3 155
listing all functions in JavaScript 19 216
The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question