• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL comparing variables

 
Ricky Jay
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


is this line of code possible?
<c:when test ="${LoadName.FirstName} eq ${firstName}">

I've tried:
<c:when test ="${LoadName.FirstName}==${firstName}">
<c:when test ="${LoadName.FirstName == firstName}">
and they don't work either.


What I'm trying to do is return to this page with server side validation errors, and reselect the values the user selected on the previous attempt. If "firstName" (the original selection) matches a name in the list, then select it.

This is my first attempt at using <c:when> and I've tried to find examples of comparing variables, but have been unsuccessful.

Am I doing something that isn't possible?

EDIT: BTW, this is loading the list box...it's just not selecting the returned value.

TY.
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need the line





Be sure that LoadName.FirstName and firstName have really the same values, try to print them out and see what happens.
 
Ricky Jay
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


It works. Thank you.
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome.

I leave a link to the J2EE tutorial's EL overview, just in case you needed a further reference.

http://java.sun.com/javaee/6/docs/tutorial/doc/bnahq.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!