zl程序教程

您现在的位置是:首页 >  后端

当前栏目

JSP指令应用实例

2023-09-14 09:04:54 时间

实训内容和要求

编写三个 JSP 页面:first.jsp、second.jsp 和 third.jsp。另外,要求用“记事本”编写一个 hello.txt 文件。

hello.txt 中的每行都有若干个英文单词,这些单词之间用空格分隔,每行之间用
分隔,如下所示:

  1. package apple void back public
  2. <br>
  3. private throw class hello welcome

实训步骤

(1) first.jsp 的具体要求。

first.jsp 使用 page 指令设置 contentType 属性的值为 text/plain,使用 include 指令静态插入 hello.txt 文件。first.jsp 的代码如下:

  1. <%@ page contentType="text/plain" %>
  2. <html>
  3. <body>
  4. <font Size=4 color=blue>
  5. <%@ include file="hello.txt" %>
  6. </font>
  7. </body>
  8. </html>

(2) second.jsp 的具体要求。

second.jsp 使用 page 指令设置 contentType 属性的值为 application/vn.ms-powerpoint,使用 include 指令静态插入 hello.txt 文件。second.jsp 的代码如下:

  1. <%@ page contentType="application/vnd.ms-powerpoint" %>
  2. <html>
  3. <body>
  4. <font Size=2 color=blue>
  5. <%@ include file="hello.txt" %>
  6. </font>
  7. </body>
  8. </html>

(3) third.jsp 的具体要求。

third.jsp 使用 page 指令设置 contentType 属性的值为 application/msword,使用 include 指令静态插入 hello.txt 文件。third.jsp 的代码如下:

  1. <%@ page contentType="application/msword" %>
  2. <html>
  3. <body>
  4. <font Size=4 color=blue>
  5. <%@ include file="hello.txt" %>
  6. </font>
  7. </body>
  8. </html>