Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How to compare a parameter value to a string literal inside EL?

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    26
    My Mood
    Fine
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question How to compare a parameter value to a string literal inside EL?

    Hi!

    How do I compare value of a parameter to a string literal inside an EL which is the value of "test" in "c:if" or "c:when"? I want to check if parameter "p" is a string "yes" but
    <c:when test="${param.p eq yes}">
    doesn't work.


  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: How to compare a parameter value to a string literal inside EL?

    Have you tried enclosing 'yes' in single quotes?

  3. The Following User Says Thank You to dlorde For This Useful Post:

    Lord Voldemort (July 28th, 2011)

  4. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    26
    My Mood
    Fine
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: How to compare a parameter value to a string literal inside EL?

    Thanks, single quotes worked. It had got into my head that single quotes were only for enclosing characters.

  5. #4
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: How to compare a parameter value to a string literal inside EL?

    I believe (it's a long time since I did any of this stuff) you can also use double-quotes (i.e. nested double quotes), and the system will figure it out, but it makes the code harder to read.

Similar Threads

  1. unclosed string literal
    By Tank314 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 23rd, 2011, 07:09 PM
  2. Convert String Literal into Operation
    By SchoolHDD in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 30th, 2010, 03:53 PM
  3. Passing JTextField as String parameter
    By Christophe in forum Java Theory & Questions
    Replies: 3
    Last Post: April 11th, 2010, 05:32 AM
  4. String + Compare // Might be too easy for ya
    By Jangan in forum Java Theory & Questions
    Replies: 1
    Last Post: October 18th, 2009, 05:40 PM
  5. literal Loop
    By chronoz13 in forum Loops & Control Statements
    Replies: 3
    Last Post: October 10th, 2009, 10:03 PM