Including Other Files
Splitting your code is one of the first techniques you can use to organize it. Many sites have a consistent header on every page. You can put the header into a separate file and include it in every page. When you need to change the header, you only need to change one file.
Within a Java Server Page, you can choose to include another file at page compile time or at runtime. The advantage of including a file at compilation time is performance. At runtime, the JSP engine doesn't need to do any work because the file has already been included. Unfortunately, the servlet engine can only include files at runtime. After all, you are the one who compiles the server—how could the servlet engine include something at compile time?
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access