• 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
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

problem with both jsp: include and %@include tags

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a situation where I need to include a certain footer into all the jsp in my application. But the footer's file name is dynamically generated at runtime. Therefore I can't use <%@include file=...> directive because it doesn't support the syntax like <%@include file = <%= footername%>....
The alternative is to use the xml tags <jsp:include page="<%=footername%>"; flush = "true"> But the problem with this tag is that it is executed at request time, instead of the raw include (at interpretation time) like <%@include>. My footer.jsp is using some of the variables in the outer jsp, and it won't compile by itself. Therefore, I will need the raw include <%@include> provides.
Does anyone have a solution for my problem? Thanks in advance.
[ January 07, 2004: Message edited by: Tom Tang ]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Surely if you don't know the name of the file until "run time", you can't include the file until "run time" ?
You seem to see some distinction between "run time", "request time", and "interpretation time", but I'm not sure what you mean by "run time" in this case.
  • JSPs have a "build time", when they are created by a developer, maybe placed in a war file, etc.
  • They also have a "deploy time", when the application placed on a server, the war is opened, and "init" methods are called for servlets marked as "load-on-startup".
  • JSPs then have a "compile time" (which happens on the first request) when the JSP code is compiled to a servlet and the "init" method is run.
  • Finally, there is a "request time" for each incoming request, when the compiled JSP code is executed to produce a resulting web page.


  • <% @include %> is processed at "compile time"
    <jsp:include> is processed at "request time"
    Can you clear up which of all these "times" your filename will be generated in ?
     
    Tom Tang
    Ranch Hand
    Posts: 133
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi, Frank:
    Thank you for taking the time to reply my post.
    By 'runtime', I mean 'request time'. The file name to include won't be known until request time. Therefore only <jsp include> is possible. I solved my problem by rewriting my footer to be a full-blown JSP which can compile by itself. I believe that's the only way out. <%@include> can't be used in my case because it is done at compile time.
     
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    tom,
    i did something similar to this, i have added footer text and header text in the runtime, i think i.e a bit similar to ur problem,
    what i did was i have included means i have used the forward page in the current jsp, from where the control will be transfered to another jsp where footer and header will be included at the run time, that jsp is getting the footer and header from a bean.
    let me give it in a detailed way
    i want a footer to appear in Jsp A in runtime.
    ok, so i forwarded that page to another jsp where the footer is coming from a bean.
    this process worked fine for me.
    just try this way.this may help u out of ur problem.
    thnx
    bhramaresh
     
    Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic