0% found this document useful (0 votes)
13 views

Lecture 11

This document discusses including static and dynamic resources in web pages. It recommends including a single navigation bar file in every page using server-side includes for efficiency. This is done by using <%@ include %> syntax to include files during page compilation. Dynamic includes can also be used by including JSP files using <jsp:include> syntax, which executes each time the page is called to generate dynamic HTML. The document provides examples of including static navbar.html and dynamic JSP files.

Uploaded by

Hop Huynh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Lecture 11

This document discusses including static and dynamic resources in web pages. It recommends including a single navigation bar file in every page using server-side includes for efficiency. This is done by using <%@ include %> syntax to include files during page compilation. Dynamic includes can also be used by including JSP files using <jsp:include> syntax, which executes each time the page is called to generate dynamic HTML. The document provides examples of including static navbar.html and dynamic JSP files.

Uploaded by

Hop Huynh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 8

Server-side

Web Programming
Lecture 11:
Modular Web Programming
Including Static Resources
• Pages on same site should have same layout
– Site identifiable to user
– User knows where to look for major components (navbar, etc.)
– Example: CSS style sheets to unify appearance
• Example: All pages on site have same navigation bar
Including Static Resources
• Bad idea: copy and paste html for navigation bar into each file
– If change layout, must modify every file on the site
• Better idea: “include” single file containing navigation bar into every
page on site
– Just need to modify single file
– Done client side with frames

navbar.htm
JSPs
included in
Server-side Includes
• Can use web container to include files
– Server page being generated for response
– Just include files
• Syntax:
<%@ include file="relative file location" %>

For example:
<%@ include file=“navbar.html" %>
Including Dynamic Resources
• Can break dynamically generated JSP into separate files
– Easier to develop and maintain as group

Configuration.jsp

Information.jsp

CreditCard.jsp
Including Dynamic Resources
• Syntax:
<jsp:include page="relative file location" />
Sample Included Page
Including Dynamic Resources
• Why different syntax?
• Steps in creating response:
1. JSP translated into an equivalent servlet.
2. Servlet is compiled.
3. The doGet or doPost method of servlet run to create response page

• <%@ include file=“…" %> executed once when compiled


– More efficient

• <jsp:include page=“…" /> must be executed every time


page called
– Will generate different html each time based on user parameters

You might also like