• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5319
  • Last Modified:

logic:equal with two variables

Is there a way of comparing two session variables using struts  logic tag.
Or
we can only compare variables with constants
0
padmasri99
Asked:
padmasri99
  • 5
  • 3
  • 2
  • +1
1 Solution
 
TimYatesCommented:
You should be able to do:

<bean:define id="valueA" value="<%= (String)session.getAttribute( "String one" ) %>"/>
<logic:equal name="valueA" value="<%= (String)session.getAttribute( "String two" ) %>">
   ...
</logic:equal>

which will compare two strings...  else, as you say, you will have to do it in 2 steps, OR doi it in JSP code...
0
 
padmasri99Author Commented:
I need to compare two bean property values and when I am doing it with bean define is setValue error in logic equal tag.Here is the code snippet.

<bean:define id="total" name="page" property="total" />
<logic:equal name="page" property="endValue" value="total">
  Do some thing
</logic:equal>

When I am defining "total" as constant in bean define it is working fine.
0
 
TimYatesCommented:
Have you tried:

<logic:equal name="page" property="endValue" value="<%= total %>">

that probably wont work either though... I *believe* logic:equal only compares string values...

So as I said, you will probably have to do this with code...rather than the logic:equal tag
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
padmasri99Author Commented:
Yes I tried with scrilets (value="<%= total %>")also it also ended up in error.
Is there any way to do this with tags?
0
 
padmasri99Author Commented:
I am able to do this with JSTL
<c:if test="${page.endValue != page.totalValue}">
Thanks for the help
0
 
TimYatesCommented:
>  I am able to do this with JSTL
>  <c:if test="${page.endValue != page.totalValue}">

Yeah, jstl uses expression parsing to allow you to do this...unfortunately, there is no way to do this with struts...

that looks like a good hybrid solution :-)
0
 
TimYatesCommented:
I think this should be a PAQ and refund...  I did nothing more than emotional support ;-)

Keep up the good work though girionis!  My inbox is a testament to the work you have done over the last day or two!!

*faint* ;-)

Tim
0
 
girionisCommented:
Hello Tim, you stated that there is no way to do it with Struts and I reckon this is the solution.

> My inbox is a testament to the work you have done over the last day or two!!

Yes I know, I have done all the questions in the JSP category (not so many though), now I have plenty of time :)
0
 
TimYatesCommented:
>  Hello Tim, you stated that there is no way to do it with Struts and I reckon this is the solution.

:-)  Cool...  I guess we'll have to wait the 4 days, and see if padmasri99 makes a comment or not :-)

God, I tried doing the cleanup once, I managed it for a couple of weeks before the workload drove me mad...

It's a thankless task generally, so again I thank you for doing it :-)

Good luck with beating me soundly in the Java TA ;-)  *grrr* ;-)

hahaha

Tim
0
 
girionisCommented:
> Good luck with beating me soundly in the Java TA ;-)

Hehe that was when I literally had no work at all :) Good you were busy back then otherwise I would still be 100,000 points behind :)
0
 
a_bajpayeeCommented:
>> Yes I tried with scrilets (value="<%= total %>")also it also ended up in error.

I would try value="<%= total.toString() %>"
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now