Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2. Simple JSPs > When Do Includes Happen?

When Do Includes Happen?

As noted, each JSP goes through two distinct phases. The first, when the JSP Engine turns the file into a servlet, is called " translation time. " The second, when the resulting servlet is run to actually generate the page, is called " request time. " Different things happen in each phase, and the distinction is important.

The include directive is handled by the JSP Engine at translation time. Incidentally, it is called a "directive" because it directs the JSP Engine to do something—in particular to open the included file and place its contents directly into the servlet it builds. This has pros and cons. On the plus side, the servlet will not have to open and include the file each time it runs and so will run faster. On the minus side, if the included file changes, the servlet will have no way to know that it should update itself. In fact, this is not a serious problem, as it will always be possible to make the JSP Engine regenerate all the servlets that might include some other file. The details may vary between implementations. Under Tomcat it is just necessary to shut down and restart the server.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial