Tài liệu Include file and applet

  • Số trang: 28 |
  • Loại file: PDF |
  • Lượt xem: 210 |
  • Lượt tải: 0
tranphuong

Đã đăng 59174 tài liệu

Mô tả:

Including Files and Applets in JSP Pages 1 Table of content  The jsp:include action Using jsp:include to include pages at request time.  The include directive To include files at page translation time.  The jsp:plugin action To include applets for the Java Plug-in. 2 Including Pages at RequestTime: jsp:include  Format   Purpose  To reuse JSP, HTML, or plain text content  To permit updates to the included content without changing the main JSP page(s) 3 Including Pages at RequestTime: jsp:include • Function A portable mechanism that lets you insert any of the following into the JSP output: The content of an HTML page The content of a plain text document The ouput of JSP page The output of a servlet 4 Including Pages at RequestTime: jsp:include  The page Attribute:  URLs that do not start with a slash are interpreted relative to the location of the main page( main directory).  URLs that start with a slash are interpreted relative to the base Web application directory, not relative to the server root. http://host/headlines/sports/table-tennis.jsp. Ex:  5 Including Pages at RequestTime: jsp:include  Notes  Output  You  Url can not contain JSP. are permitted to include files from WEB-INF. start with slashes  The server always interprets them relative to the current Web application.  The browser always interprets them relative to the server root. 6 Including Pages at RequestTime: jsp:include The flush Attribute  This attribute is optional.  The output stream of the main page should flushed before the inclusion of the page 7 Including Pages at RequestTime: jsp:include  Example: A news Headline page … Here is a summary of our three most recent news stories:
8 Including Pages at RequestTime: jsp:include 9 Including Files at Page Translation Time: <%@ include … %>  Format  <%@ include file="Relative address" %>  Purpose  To reuse JSP content in multiple pages 10 Including Files at Page Translation Time: <%@ include … %>  Example The include Directive Example

The include Directive Example



<%@ include file="footer.jsp" %> <%-- footer.jsp --% >

Copyright © 2010

Including Files at Page Translation Time: <%@ include … %>  Differences between jsp:include and include directive 12 Including Files at Page Translation Time: <%@ include … %>  Example: Reusing Footers SomeRandomPage.jsp ContactSection.jsp …… bla, bla bla <%@ include file="/WEBINF/ContactSection.jsp" %> <%! private int accessCount = 0; private Date accessDate = new Date(); %> …… This page has been accessed <%= ++accessCount %> at <%= accessDate %>. 13 Including Files at Page Translation Time: <%@ include … %>  Example: Reusing Footers 14 Applets and jsp:plugin  What is applets 15 Applets and jsp:plugin  What is applets 16 Applets and jsp:plugin   Why Applets?  When UI requirements demand it  Major drawbacks  Alternatives Options for Deploying Applets  Develop the applets with JDK 1.1 or even 1.02  Have users install any version of the Java 2 Plug-in, then use Java 2 for the applets  Have users install version 5 or 6 of the Java Runtime Environment (JRE), then use JDK 1.5/1.6 for the applets 17 Applets and jsp:plugin  Using jsp:plugin  APPLET Tag  Equivalent jsp:plugin 18 Applets and jsp:plugin  WindowUtilities.java Example PluginApplet.jsp public static void setNativeLookAndFeel() PluginApplet.java public void init() TextPanel.java DrawingPanel drawingPanel; public TextPanel() DrawingPanel.java public void paintComponent(Graphics g) public void setFontName(String fontName) 19 Applets and jsp:plugin  Example 20
- Xem thêm -