• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

c:if tag

 
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to check if the value of the variable equals any of the possible 4 values like val1,val2,val3 , val4 i.e. if the value is other than val4 then format the page in A format else format it in B format.

Thanks,
Trutpi
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would you construct such a test if you were writing a Java if statement?
 
trupti nigam
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
How would you construct such a test if you were writing a Java if statement?



OK I would write something like below:

if(name == val1 || name== val2|| name==val3){
//format jsp in first way
}else{
//format JSP in second way
}

I am not sure how to combine the or statement using the JSTL tags also is there in else?

Thanks,
Trupti
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are writing JSPs you need to have a copy of the JSP spec open on your desk. The section on the EL will let you know what operators exist that you can use.
 
trupti nigam
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
If you are writing JSPs you need to have a copy of the JSP spec open on your desk. The section on the EL will let you know what operators exist that you can use.



That is the first thing I would do. I tried searching the google and other resources but could not find how to use "or" in the JSTL <c:if> tag.

Thought about posting it on Javaranch.

Thanks,
Trupti
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you coiuld use the <c:choose> tag. It has c <c:otherwise> sub tag
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A link to the JSP Specification can be found in the JSP FAQ.
 
trupti nigam
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Ku:
you coiuld use the <c:choose> tag. It has c <c:otherwise> sub tag



But Can I use the "or" condition within <c:choose>

As I do not want to repeat the same code within different <c:choose> condtions.

In Java my condition would be
if(name=='A1'|| name=='A2'||name=='A3')
{
//format in style 1
}
else{
//format in style 2
}


Thanks,
Trupti
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The idiom for an if-then-else in the JSTL:



It is completely independent of the what operators you use within the condition expression.
[ August 13, 2007: Message edited by: Bear Bibeault ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic