1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Modular web programming (lập TRÌNH WEB SLIDE)

8 8 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 8
Dung lượng 383 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

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 shee

Trang 1

Server-side Web Programming

Lecture 11:

Modular Web Programming

Trang 2

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

Trang 3

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

Trang 4

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" %>

Trang 5

Including Dynamic Resources

• Can break dynamically generated JSP into separate files

– Easier to develop and maintain as group

Configuration.jsp

Information.jsp

CreditCard.jsp

Trang 6

Including Dynamic Resources

• Syntax:

<jsp:include page="relative file location" />

Trang 7

S

Trang 8

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

Ngày đăng: 29/03/2021, 10:55

TỪ KHÓA LIÊN QUAN

w