<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 23,comments - 12,trackbacks - 0

    The include Directive


    The following is the syntax for the include directive:

    <%@ include file="relativeURL" %>

    As you can see the directive accepts a single file attribute that is used to indicate the resource whose content is to be included in the declaring JSP. The file attribute is interpreted as a relative URL; if it starts with a slash it's interpreted as relative to the context of the web application (namely a context-relative path), otherwise it's interpreted as relative to the path of the JSP that contains the include directive (namely a page relative path). The included file may contain either static content, such as HTML or XML, or another JSP page.

    For example:
    <%@ include file="/copyright.html"%>


    Let's consider a real-world example of such a templating mechanism that utilizes the include directive to provide a consistent page layout for a web application.

    Consider the following two JSP pages:

    Header.jsp
        <html>
          <head><title>A Very Simple Example</title></head>
          <body style="font-family:verdana,arial;font-size:10pt;">
            <table width="100%" height="100%">
              <tr bgcolor="#99CCCC">
                <td align="right" height="15%">Welcome to this example...</td>
              </tr>
              <tr>
                <td height="75%">

    Footer.jsp
               </td>
             </tr>
             <tr bgcolor=" #99CC99">
               <td align="center" height="10%">Copyright ACompany.com 2003</td>
             </tr>
           </table>
         </body>
       </html>

    As you can see, Header.jsp declares the starting elements of an HTML table that is to be 100 percent of the size of the page and has two rows, whereas Footer.jsp simply declares the closing elements for the table. Used separately, either JSP will result in partial HTML code that will look very strange to a user but when they're combined using the include directive it's easy to create consistent pages as part of a web application.

    Let's see just how simple this basic template mechanism is to use:

    Content.jsp
        <%@ include file='./Header.jsp'%>
        <p align="center">The Content Goes Here...!!!</p>
        <%@ include file='./Footer.jsp'%>

    2、
    date.jsp
    <html>
      <body>
        <h2>Greetings!</h2>
     <P>The current time is <%=new java.util.Date()%> precisely
      </body>
    </html>

    3、
    dateBean.jsp
    <html>
        <head><title>Professional JSP, 3rd Edition</title></head>
        <body style="font-family:verdana;font-size:10pt;">
            <jsp:useBean id="date" class="com.apress.projsp20.ch01.DateFormatBean"/>
            <h2>Today's date is <%= date.getDate() %></h2>
        </body>
    </html>

    或:
    dateBean_getProperty.jsp
    <html>
        <head><title>Professional JSP, 3rd Edition</title></head>
        <body style="font-family:verdana;font-size:10pt;">
            <jsp:useBean id="date" class="com.apress.projsp20.ch01.DateFormatBean"/>
            <h2>Today's date is <jsp:getProperty name="date" property="date"/></h2>
        </body>
    </html>

    dateBean_setProperty.jsp
    <html>
        <head><title>Professional JSP, 3rd Edition</title></head>
        <body style="font-family:verdana;font-size:10pt;">
            <jsp:useBean id="date" class="com.apress.projsp20.ch01.DateFormatBean"/>
            <jsp:setProperty name="date" property="format"
                             value="EEE, d MMM yyyy HH:mm:ss z"/>
            <h2>Today's date is <jsp:getProperty name="date" property="date"/></h2>
        </body>
    </html>

    其中DateFormatBean.java:
       package com.apress.projsp20.ch01;

        import java.util.Date;
        import java.text.*;

        public class DateFormatBean {
          private DateFormat dateFormat;
          private Date date;

          public DateFormatBean() {
            dateFormat = DateFormat.getInstance();
            date = new Date();
          }

          public String getDate() {
            return dateFormat.format(date);
          }

          public void setDate(Date date) {
            this.date = date;
          }

          public void setFormat(String format) {
            this.dateFormat = new SimpleDateFormat(format);
          }
        }
    例:SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    posted on 2005-08-24 17:20 my java 閱讀(301) 評論(0)  編輯  收藏 所屬分類: jsp

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 成人免费视频77777| 国产福利视精品永久免费| 精品剧情v国产在免费线观看| 久久久国产精品亚洲一区| 91免费福利精品国产| 亚洲乱码精品久久久久..| a级精品九九九大片免费看| 亚洲香蕉成人AV网站在线观看| a免费毛片在线播放| 亚洲精品国产成人片| 暖暖免费在线中文日本| 亚洲综合国产精品| 99久久99久久精品免费看蜜桃| 亚洲一级毛片在线观| 德国女人一级毛片免费| 在线观看国产一区亚洲bd| 亚洲国产精品碰碰| 在线涩涩免费观看国产精品| 无限动漫网在线观看免费| 亚洲精品无码专区在线播放| 国产免费人视频在线观看免费| 一本久久免费视频| 四色在线精品免费观看| 日亚毛片免费乱码不卡一区| 亚洲人成网77777色在线播放| 91香焦国产线观看看免费 | 亚洲Av熟妇高潮30p| 久久九九兔免费精品6| 亚洲国产AV无码一区二区三区| 亚洲A丁香五香天堂网| 日本免费人成网ww555在线| 亚洲成a人片在线观| 免费一级黄色毛片| 成人性做爰aaa片免费看| 久久精品国产亚洲AV蜜臀色欲| 免费看国产精品麻豆| 无码人妻AV免费一区二区三区| 亚洲免费福利在线视频| 久久久久亚洲精品天堂久久久久久 | 88xx成人永久免费观看| 亚洲乱色伦图片区小说|