• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL String comparison problem

 
Simmi Chako
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having issues with string comparison after retrieving data from XML in JSTL. I have this XML
<matrix>
<column name="Retention" >
<object name="ROSS" />
<object name="Test Software Component 2" />
<object name="Software Component 555" />
</column>
<column name="Temporary" >
<object name="ROSS"/>
<object name="Software Component 555" />
</column>
<column name="Permanent" >
<object name="Test Software Component 2" />
</column>
<matrix>

The code that compares the data is:

<x:forEach var="colnodesName" select="$sessionScope:xmlData/matrix/column">
<x:forEach var="colnodesNameObj" select="$colnodesName/object">
<x:set var="objname" select="$colnodesNameObj/@name"/>
<tr><cut value="${currName} : ${objname} : ${currName == objname}"/>

</x:forEach>
</x:forEach>



The output I get is:

[name="Test Software"] : [name="Test Software"] : false

I even tried <cut value="${currName.value} : ${objname.value} : ${currName.value == objname.value}"/>
But this does not give me any output infact it gives me a blank page.

Can anyone help me please
Thanks in advance
Any help will really be appreciated!
[ February 26, 2008: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"shimmering trinkets", please check your private messages for an important administrative matter.
 
Simmi Chako
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for letting me know about it! I have update my profile.
Now plzzz can someone respond to my problem!! It is really important!
Thanks a million
 
Elie Hirschman
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would try using eq instead of ==
Not sure, but this is always one thing that trips me up when dealing in JSTL.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Simmi Chako:
Now plzzz can someone respond to my problem!

One more thing, please use real words when posting to the forums. Abbreviations such as "plzzz" in place of "please" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Elie Hirschman:
I would try using eq instead of ==

They are equivalent.
 
Simmi Chako
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried with eq also, It does not work!
It is kind of strange as to why it is not working as the values appear to be the same. I even calculated the length of the strings which also comes equal so I am sure it is not appending any characters or anything to the string.
Can you guys look into it.

Thank You!
 
Paul Clapham
Sheriff
Posts: 21862
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So... are you actually comparing two String variables, or are you comparing two nodeset variables whose text content happens to be the same? If they were String variables then I think the comparison would work the way you expect it to work. But it doesn't. Therefore you aren't comparing two String variables.
 
Simmi Chako
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah I am not comparing two string varibales but i am comparing values of two nodes. I am trying to do so by storing the value of the nodes in a variable. This is what is the output I am getting:
[name="Test Software"] : [name="Test Software"] : false

Thank You!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!