• 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

multiple JSPs: order of execution

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a JSP (main.jsp) with a javascript file referenced within the HTML HEAD tag. Since the javascript needs to populate certain arrays from the session bean, it is itself a JSP (js.jsp). This array population code exists outside of any function calls.

The bean caches certain properties that must be loaded from the database, such that multiple calls only go out to the database once. Both main.jsp and js.jsp need a certain property (the same one). For testing purposes, I have added alert boxes to both code blocks.

All of this works fine, but this sequence seems surprising:

1) js.jsp alert box announces it accessed the bean property second.
2) main.jsp alert box announces it accessed the bean property first.

I expected js.jsp to alert first, running from HEAD, but i didn't expect main.jsp to get to the bean first, for the same reason.

Is the order of execution for various JSPs that contribute to the final markup specified ... e.g., embedded JSPs always run after containing JSPs?

What if there are also include-directive JSPs ... is order of execution specified simply to follow the (linear) order that embedded JSPs are encountered in the containing JSP, regardless of any enclosing semantic elements, but only after the containing JSP is run?

Thanks!
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should be main.jsp first because js.jsp acts as a script file, it will be loaded by the browser as directed in the main.jsp (i.e. after the server process main.jsp).

The sequences are:
(1) Browser requests main.jsp
(2) Server processes main.jsp, send to browser
(3) Browser parses main.jsp for any related resources (i.e. script and/or css and/or image files)
(4) Browser requests to load related resource files
(5) Server processes related resources (i.e. js.jsp) and send to browser

Hope it is clear to you now.
 
Paul Fenerty
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
of course! run only at request time ... thanks!
 
Why is the word "abbreviation" so long? And this ad is so short?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic