• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Conditional includes

 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So here is what I'd like to be able to do:
This of course, doesn't work.

In english: I need to retrieve a parameter and depending on that parameter, fill in an area of my page with one of five different pages. I am probably missing the easiest solution, because right now I just can't see how to do this sort of thing, but it obviously has to be possible!
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Try this..
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had not thought of that, and I think I once wrote ASP pages like this... but here is what it gave me:

But another problem, even if this did work. Doesn't this approach assume that JSP's get processed in a 'dual pass' mode. One pass would have to be for the 'if' selection part, and the second part would actually have to do the jsp:include.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, that was the right suggestion with one modification. It needed the { and } braces.
What confused me about the 'dual pass', is that I forgot that the jsp:include tag gets translated by the JSP compiler into actual java code that gets the requestdispatcher etc, etc... and that all three conditions are actually compiled into the servlet, but of course only one of them gets performed at request-time, based on that variable. I was thinking that the JSP compiler would take the <jsp:include....> tag and turn it into an out.println("<jsp:include...>"); but of course this doesn't happen, because it's outside the <% %>'s.

Thanks for the help.
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You beat me to the punch.. most welcome
 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip.
I got conditional including jsp working.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
test
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you could also do this with a JSTL tag, if you want to avoid scripting


cheers,
Kathy

p.s. I edited this to keep the colon: and o from turning into THIS guy So... there is NOT supposed to be a space between the ":" and "o" in the <c: otherwise> Anyone know how to disable the graemlins? Thanks!
[ June 24, 2004: Message edited by: Kathy Sierra ]
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a nice little checkbox on the bottom of the page just above the lower "Add Reply" button labelled "Disable smilies in this post." that will disable smilies
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kathy for the tip.
This thread started 3 years ago and technology has advanced since then!
The tag solution is better I think.
 
Karthikeyan Dharmarajan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
test
 
Karthikeyan Dharmarajan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bruce Jin:
Thanks Kathy for the tip.
This thread started 3 years ago and technology has advanced since then!
The tag solution is better I think.



test
 
Karthikeyan Dharmarajan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bruce Jin:
Thanks Kathy for the tip.
This thread started 3 years ago and technology has advanced since then!
The tag solution is better I think.


========
test

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic