This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Conditional includes  RSS feed

 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • 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!
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Try this..
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
You beat me to the punch.. most welcome
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the tip.
I got conditional including jsp working.
 
Karthikeyan Dharmarajan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
test
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • 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 ]
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
test
 
Karthikeyan Dharmarajan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
  • 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

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