Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Include Statements  RSS feed

Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been reading through HFS&J and I came up with a question while I was going through the review regarding the include page directive and the include standard action.

Let's say I use an include directive in my file A.jsp, which includes the file B.jsp. The first time A.jsp is requested, the contents of B.jsp are copied into A.jsp and the resulting file is then translated into a Java Servlet. Obviously, as servlets are only translated once, if I then change B.jsp and request A.jsp, I don't see the new changes because A.jsp has already been translated. (Granted, I believe the text says that some containers can catch that.)

However, with the <jsp:include> standard action, I'm a little confused. Once again, let's say I'm including B.jsp in A.jsp, but this time, I'll use a standard action to perform the inclusion. The first time A.jsp is requested, it is translated into a servlet - that servlet contains a forward to B.jsp. When this servlet's service method is executed, it forwards the request to B.jsp, which also needs to be translated and initialized. When B.jsp has completed its service method, execution returns to A.jsp's service method.

Now, if I change B.jsp at this point, would I see the change? If B.jsp has already been translated into a servlet, would the container automatically re-translate it when B.jsp is included via A.jsp again? I assumed that, once B.jsp has been translated, it would never be translated again (until it was redeployed). However, in the summary, the text states:

The <jsp:include> standard action includes the response of the included page into the original page at runtime. So the include standard action is considered appropriate for including content that may be updated after deployment, while the include directive is not.

That statement leads me to believe that every time B.jsp is included in A.jsp (via standard action, not directive), B.jsp is retranslated and initialized. If that's the case, how big of a performance hit is this on real-world systems?

Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 ways to include a JSP: static include vs dynamic include.

If you include the page using directive, it is regarded as static include, and it is done in complication time.

If you include the page using action tag, it is regarded as dynamic include, and it is done in runtime.

Thus, you find that, if you change something. For static include, the changes do not reflect even you reload the page, however, for dynamic include, the changes DO reflect.

I think this will not be a problem becos only modified page will trigger the recomplication.


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