jsp内置对象


目录

前言

一、request对象

1.1 获取用户提交的信息

 1.2 处理汉字信息

1.3 处理HTML标记

1.3.1 form标记(form表单)

 1.3.2 input标记

1.3.3 select、option标记 

 1.3.4 textArea标记

1.3.5 style样式标记

1.3.6 table 标记

1.3.7image标记

 1.3.8 embed标记

 1.4 处理超链接

二、response对象 

2.1 动态响应contentType属性

2.2response对象的重定向

三、session对象 

3.1 session对象的id

3.2 session对象与URL重写

3.3 session对象存储数据

3.4 session对象的生存期限

四、application对象

4.1 application对象的常用方法

4.2 application留言板

总结



前言

本次介绍的为jsp的四个内置对象,request对象,response对象,session对象,application对象。其中难点为session对象的理解和使用。


一、request对象

http通信协议是用户与服务器之间一种提交(请求)信息与响应信息(request/response)的通信协议。在jsp中,内置对象request封装了用户提交的信息,那么该对象调用相应的方法可以获取封装的信息,即使用该对象可以获取用户提交的信息。

用户常用html的form表单(form标记)请求访问服务器的某个jsp网页(或servlet),并提交必要信息给所请求的jsp页面,表单的一般格式是:

<form action = "请求访问的jsp页面或Servlet" method = get|post>
提交手段
</form>

其中action为form表单的属性,其属性值给出表单请求访问的jsp页面或servlet。method属性取值为get或post,其区别为使用get方法提交的信息会在提交的过程中显示在浏览器的地址栏中,而post方法不会。

1.1 获取用户提交的信息

request对象获取用户提交的信息最常用的方法是getParameter(String s)。

例:

example4.1.jsp

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %> 
<HTML><body bgcolor = #ffccff> 
   <form action="example4_1_computer.jsp" method=post >
       <input type="text" name="sizeA" value=9 size=6 />
       <input type="text" name="sizeB" value=8 size=6 /> 
       <input type="text" name="sizeC" value=8 size=6 />
       <input type="submit" name="submit" value="提交"/>
   </form> 
</body></HTML>

 example4.1.computer.jsp

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %> 
<HTML><body bgcolor = #ccffff>
<p style="font-family:黑体;font-size:36;color:blue">
<%  
    String sideA=request.getParameter("sizeA");
    String sideB=request.getParameter("sizeB");
    String sideC=request.getParameter("sizeC");
    try {  double a=Double.parseDouble(sideA);
           double b=Double.parseDouble(sideB);
           double c=Double.parseDouble(sideC);
           double p=(a+b+c)/2,area=0;
           area=Math.sqrt(p*(p-a)*(p-b)*(p-c));
           String result = String.format("%.2f",area);
           out.println("<BR>三边:"+sideA+","+sideB+","+sideC);
           out.println("<BR>三角形面积(保留2位小数):"+result);
    }
    catch(NumberFormatException ee){
          out.println("<BR>请输入数字字符");
    } 
%>
</p></body></HTML>

运行结果:

 1.2 处理汉字信息

request对象获取用户提交的信息中如果含有汉字字符或其他非ASCLL字符,就必须进行特殊的处理方式,以防乱现象。

jsp页面的编码为UTF-8,所以让request对象在获取用户提交的信息之前将编码设置为UTF-8即可避免乱码现象:使用setCharacterEncoding方法

request.setCharacterEncoding("utf-8");

例:

example4.2

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %> 
<style>
   #tom{
      font-family:宋体;font-size:26;color:blue 
   }
</style> 
<HTML><body id="tom" bgcolor = #ffccff>
可以输入各种语言的文字,单击提交键:
<%
   String content = "早上好,Good morning,อรุณสวัสดิ์ค่ะ(泰语),"+
                  " おはよう,Доброе утро,좋은 아침";
%>
<form  action="" method='post' >
   <textArea  name="language" id="tom" rows=3 cols=50>
      <%= content %>
   </textArea>
   <input type="submit" id="tom" name="submit" value="提交"/>
</form>  
<%   request.setCharacterEncoding("utf-8");
     String variousLanguages=request.getParameter("language");
     out.print(variousLanguages);
%>
</p></body></HTML>

运行结果:

1.3 处理HTML标记

1.3.1 form标记(form表单)

form表单的一般格式是:

<form action = "请求访问的jsp页面或Servlet" method = get|post>
提交手段
提交键
</form>

 <form>为开始标签,</form>为结束标签。其中action为form表单的属性,其属性值给出表单请求访问的jsp页面或servlet。method属性取值为get或post,其区别为使用get方法提交的信息会在提交的过程中显示在浏览器的地址栏中,而post方法不会。提交手段包括文本框,列表,文本区:

<form action = "tom.jsp" method = "post">

<input type = "text" name = "boy" value = "ok" / >

<input type = "submit" name = "submit" value = "提交">

</form>

 1.3.2 input标记

input标记作为子标记来指定form表单中数据的输入方式和form表单的提交键。input标记为空标记没有标记体,所以没有开始和结束标签。input标记的基本格式为:

<input type="GUI对象" name="GUI对象的名字" value="GUI中的默认值" />

GUI对象有:

①文本框text ②单选框radio ③复选框checkbox ④口令框password ⑤隐藏hidden ⑥提交键submit

⑦重置键reset

例:

example4.5.jsp

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %> 
<style>
   #tom{
      font-family:宋体;font-size:26;color:blue 
   }
</style> 
<HTML><body id="tom" bgcolor = #ffccff>
<form action="example4_5_receive.jsp" method=post id=tom>
  <br>音乐:
  <input type="radio" name="R" value="on" />打开 
  <input type="radio" name="R" value="off" checked="default">关闭 
<br>哪些是奥运会项目:<br> 
  <input type="checkbox" name= "item" value="A"  algin= "top"  />足球
  <input type="checkbox" name= "item" value="B"  algin= "top"  />围棋
  <input type="checkbox" name= "item" value="C"  algin= "top"  />乒乓球
  <input type="checkbox" name= "item" value="D"  algin= "top"  />篮球
  <input type="hidden" value="我是球迷,但不会踢球" name="secret"/>
  <br><input type="submit" id="tom" name="submit" value="提交"/>
  <input type="reset" id="tom" value="重置" />
</form> 
</body></HTML>

example4.5receive.jsp

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %> 
<%@ page import  = "java.util.Arrays" %> 
<%! public boolean isSame(String []a,String [] b){
         Arrays.sort(a); 
         Arrays.sort(a);
         return Arrays.equals(a,b);
    }
%>
<HTML><body bgcolor = white >
<p style="font-family:宋体;font-size:36;color:blue"> 
<%   String answer[] = {"A","C","D"};
     request.setCharacterEncoding("utf-8");  
     String onOrOff=request.getParameter("R"); //获取radio提交的值
     String secretMess=request.getParameter("secret");//获取hidden提交的值
     String itemName[]=request.getParameterValues("item"); //获取checkbox提交的值
     out.println("<br> 是否打开音乐:"+onOrOff);
     out.println("<br> 您的答案:");
     if(itemName==null) {
          out.print("没给答案");
     } 
     else {
         for(int k=0;k<itemName.length;k++) {
           out.print(" "+itemName[k]);
         }
         if(isSame(itemName,answer)){
           out.print("<br>回答正确。");
         }
     }
     out.println("<br> 提交的隐藏信息:"+secretMess);
     if(onOrOff.equals("on")) {
%>       <br><embed src="sound/back.mp3" />
<%   } 
%>
</p></body></HTML>

运行结果:

1.3.3 select、option标记 

下拉式列表和滚动列表通过select和option标记来定义。select标记将option标记作为子标记形成下拉列表和滚动列表

下拉列表:

<select name ="Name">
<option value="item1">文本描述</option>
<option value="item2">文本描述</option>
...
</select>

 滚动列表,在select中增加size属性,size属性的值为滚动列表的可见行数。

<select name ="Name" size="正整数">
<option value="item1">文本描述</option>
<option value="item2">文本描述</option>
...
</select>

 1.3.4 textArea标记

此标记是一个能输入或显示多行文本的文本区。其格式为:

<textArea name="名字" rows="文本可见行数" col="文本可见列数">
</text>

1.3.5 style样式标记

style标记可用于定义HTML其他标记的字体样式,例如:
 

<style>
 #textStyle{
    font-family:宋体;font-size:18;color:white
}
# tom{
    font-family:宋体;font-size:18;color:white
}
</style>

其他HTML标记可以让增加的id属性是样式的名称来使用这个样式

1.3.6 table 标记

表格以行列形式显示数据,不提供输入数据功能:

<table border="边框的宽度">
     <tr width="该行的宽度">
        <th width="单元格的宽度">单元格中的数据</th>
        ...
        <th width="单元格的宽度">单元格中的数据</th>...
     </tr>
...
</table>

1.3.7image标记

使用此标记可以显示一幅图像:
 

<image src = "图像文件的url">描述文字</image>
图像的url 如果图像文件和当前页面在同一Web服务目录则url为图像的名字,如果在当前Web服务目录的一个子目录则为"子目录的名字/图像文件的名字"

 1.3.8 embed标记

使用此标记可以播放音乐和视频:

<embed src = "音乐或视频文件的url">描述文字</image>
音乐或视频文件的urlj 如果音乐或视频文件和当前页面在同一Web服务目录则url为音乐或视频文件的名字,如果在当前Web服务目录的一个子目录则为"子目录的名字/音乐或视频文件的名字"

 1.4 处理超链接

HTML的超链接标记:

<a href = 链接的页面地址>文字说明</a>

用户点击超链接标记的文字说明,可以访问超链接给出的链接页面。使用超链接标记时还可以增加参数。

<a href = 链接的页面地址?参数1=字符串1&参数2=字符串2&...>文字说明</a>

使用request.setParameter("id");获取超链接传递的参数值。

二、response对象 

2.1 动态响应contentType属性

页面用page指令设置页面的contentType属性的值,那么Tomcat服务器将按照这种属性值作出响应,将页面的静态部分返回给用户,用户浏览器接收到该响应就会使用相应的手段处理所收到的信息。由于pagBe 指令只能为contentType 指定个值来决定响应的MIME类型,如果想动态地改变这个属性的值来响应用户,就需要使用response对象的setContentType(String s)方法来改变contentType的属性值。

example4.10.jsp

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %>
<style>#textStyle
   { font-family:宋体;font-size:36;color:blue 
   }
   #tomStyle
   { font-family:黑体;font-size:26;color:black 
   }
</style> 
<HTML><body id="textStyle" bgcolor = #ffccff> 
<form action="example4_10_show.jsp"  method=post >
输入圆半径:<br>
半径:<input type="text" name="radius" id = "textStyle" value=100.8 size=12 /><br>
<input type="submit" name="submit" id = "tomStyle" value="提交看面积"/><br>
<input type="submit" name="submit" id = "tomStyle" value="提交看圆形"/>
</form> 
</body></HTML>

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %> 
<%@ page import="java.awt.*" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.awt.image.BufferedImage" %>
<%@ page import="java.awt.geom.*" %>  
<%@ page import="javax.imageio.ImageIO" %>
<style>#textStyle
   { font-family:宋体;font-size:36;color:blue 
   }
</style> 
<%! void drawCircle(double r,HttpServletResponse response) { //定义绘制圆的方法
        int width=320, height=300;
        BufferedImage image = 
        new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
        Graphics g = image.getGraphics();
        g.fillRect(0, 0, width, height);
        Graphics2D g_2d=(Graphics2D)g; 
        Ellipse2D ellipse=new Ellipse2D.Double(160-r,150-r,2*r,2*r);
        g_2d.setColor(Color.blue);
        g_2d.draw(ellipse); 
        try {
          OutputStream outClient= response.getOutputStream();//指向用户端的输出流
          boolean boo =ImageIO.write(image,"jpeg",outClient);
        }
        catch(Exception exp){}
    }
    double getArea(double r) { //定义求面积的方法
       return  Math.PI*r*r;
    }
%>
<%  request.setCharacterEncoding("utf-8"); 
    String submitValue = request.getParameter("submit");
    String radius = request.getParameter("radius");
    double r =Double.parseDouble(radius);
    if(submitValue.equals("提交看圆形")){
       response.setContentType("image/jpeg");//response更改相应用户的MIME类型
       drawCircle(r,response) ; //绘制圆
    }
%>
<HTML><body bgcolor = #EEEEFF>

<p id ="textStyle">
<%  
    double area=getArea(r);
    String result = String.format("%.2f",area);
%> 
半径:<%= radius %><br>
<b>面积(保留2位小数)<br><%= result %>
</p></body></HTML>

运行结果:

 

2.2response对象的重定向

在某些情况下,当响应用户时,需要将用户重新引导至另一个页面。例如,如果用户输人的form表单信息不完整,就会再被引导到该form 表单的输入页面。

可用response对象的sendRedirect(URL url)方法实现用户的重定向,即让用户从一个页面跳转到sendRedirect(URL url)中url指定的页面,即所谓的客户端跳转。

例example4.12

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %> 
<style>#textStyle
   { font-family:宋体;font-size:36;color:blue 
   }
</style>
<HTML><body bgcolor=#ffccff> 
<p id="textStyle">
填写姓名(<%= (String)session.getAttribute("name")%>):<br>
<form action="example4_12_receive.jsp" method="post" name=form>
   <input type="text" id="textStyle"  name="name">
   <input type="submit" id="textStyle" value="确定"/>
</form>
</body></HTML>
<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %> 
<HTML><body bgcolor = #DDEEFF> 
<%  request.setCharacterEncoding("utf-8"); 
    String name=request.getParameter("name");
    if(name==null||name.length()==0) {
       response.sendRedirect("example4_12.jsp"); 
       String str =(String)session.getAttribute("name");//这个仍然会被执行。
       session.setAttribute("name","李四"+str);//这个仍然会被执行。
    }
%> 
<b>欢迎<%= name %>访问网页。
</body></HTML>

运行结果:

三、session对象 

3.1 session对象的id

当一个客户首次访问服务器上的一个JSP 页面时,JSP 引擎产生一个secssion 对象,这个session 对象调用相应的方法可以存储客户在访问各个页面期间提交的各种信息。这个session 对象被分配了一个String 类型的Id 号,JSP 引擎同时将这个Id 号发送到客户端,存放在客户的Cookie 中。这样,session 对象和客户之间就建立起一一对应的关系,即每个客户都对应着一个session 对象(该客户的会话),这些session 对象互不相同,具有不同的Id 号码。JSP 引擎为每个客户启动一个线程,也就是说,JSP 为每个线程分配不同的session 对象。当客户再访问连接该服务器的其它页面时,或从该服务器连接到其它服务器再回到该服务器时,JSP 引擎不再分配给客户的新session 对象,而是使用完全相同的一个,直到客户关闭浏览器后,服务器端该客户的session对象被取消,和客户的会话对应关系消失。当客户重新打开浏览器再连接到该服务器时,服务器为该客户再创建一个新的session 对象。

例3.1

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %>
<style>#textStyle
   { font-family:宋体;font-size:36;color:blue 
   }
</style> 
<HTML><body bgcolor=#ffccff> 
<p id="textStyle"> 
这是example4_13_a.jsp页面<br>单击提交键连接到example4_13_b.jsp
<% String id=session.getId();
   out.println("<br>session对象的ID是<br>"+id);
%>
<form action="example4_13_b.jsp" method=post name=form>
  <input type="submit" id="textStyle" value="访问example4_13_b.jsp" />
</form>  
</body></HTML>

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %> 
<style>#textStyle
   { font-family:黑体;font-size:36;color:red 
   }
</style> 
<HTML><body bgcolor=cyan> 
<p id="textStyle">  
这是example4_13_b.jsp页面
<%  String id=session.getId();
    out.println("<br>session对象的ID是<br>"+id);
%>
<br>连接到example4_13_a.jsp的页面。<br>
<a href="example4_13_a.jsp">example4_13_a.jsp</a>   
</body></HTML>

运行结果:

 

3.2 session对象与URL重写

 session 对象能和客户建立起一一对应关系依赖于客户的浏览器是否支持Cookie。如果客户端不支持Cookie,那么客户在不同网页之间的session 对象可能是互不相同的,因为服务器无法将Id 存放到客户端,就不能建立session 对象和客户的一一对应关系。
 将浏览器的Cookie 设置为禁止后(选择浏览器菜单→工具→Internet 选项→安全→internet 和本地intranet→自定义级别→cooker,将全部选项设置成禁止),“同一客户”对应了多个session 对象,这样服务器就无法知道在这些页面上访问的实际上是同一个客户。

  如果客户的浏览器不支持 Cookie,我们可以通过URL 重写来实现session 对象的唯一性。所谓URL 重写,就是当客户从一个页面重 新连接到一个页面时,通过向这个新的URL 添加参数,把session 对象的Id 传带过去,这样就可以保障客户在该网站各个页面中的session。可以使用response 对象调用encodeURL()或encodeRedirectURL()方法实现URL重写。

3.3 session对象存储数据

1) public void setAttribute(String key ,Object obj)
   调用该方法将参数Object 指定的对象obj 添加到session 对象中,并为添加的对象指定了一个索引关键字,如果添加的两个对象的关键字相同,则先前添加的对象被清除。

2) public Object getAttibue(String key)
   获取session 对象含有的关键字是key 的对象。

3) public Enumeration getAttributeName()
   调用该方法产生一个枚举对象,该枚举对象使用nextElemets()遍历session 对象所含有的全部对象。

4) public void removeAttribue(String key)
   从当前session 对象中删除关键字是key 的对象。

3.4 session对象的生存期限

一个用户在某个Web服务目录的session对象的生存期限依赖于session对象是否调用invalidate()方法使得session对象无效或session对象达到了设置的最长的发呆状态时间以及用户是否关闭浏览器或服务器被关闭。

session对象可以使用以下方法获取或设置生存时间有关的信息

(1) public long getCreationTime()
   获取session对象创建的时间,单位是毫秒(从1970 年7 月1 日午夜起至该对象创建时刻所走过的毫秒数)。

(2) public long getLastAccessedTime()
   获取当前session 对象最后一次被操作的时间,单位是毫秒。

(3) public int getMaxInactiveIterval()
   获取session 对象的生存时间。
(4) public void setMaxInactiveIterval(int n)
   设置session 对象的生存时间(单位是秒)

(5) invalidate()
   使得session 无效。  

四、application对象

4.1 application对象的常用方法

 (1) public void setAttribute(String key ,Object obj) 
   application 对象可以调用该方法将参数Object 指定的对象 obj添加到application 对象中,并为添加的对象指定了一个索引关 
  键字,如果添加的两个对象的关键字相同,则先前添加对象被清除。 
(2) public Object getAttibue(String key) 
   获取application 对象含有的关键字是key 的对象。 
(3) public Enumeration getAttributeNames() 
   application 对象调用该方法产生一个枚举对象,该枚举对象使用nextElemets()遍历application 对象所含有的全部对象。 
(4) public void removeAttribue(String key) 
   从当前application 对象中删除关键字是key 的对象。 
(5) public String getServletInfo() 
   获取Servlet 编译器的当前版本的信息。 

由于 application 对象对所有的客户都是相同的,任何客户对该对象中存储的数据的改变都会影响到其他客户,因此,在某些情况下, 对该对象的操作需要实现同步处理。

4.2 application留言板

使用application内置对象,让其担任留言板的角色,同时设置留言板最多可以留言99999条,即application对象用1到99999之间的一个整数作为关键字(key)存放一条留言

example4.16.jsp

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %>
<HTML>
<style>
   #textStyle{
      font-family:宋体;font-size:18;color:blue 
   }
</style>
<body id='textStyle' bgcolor = #ffccff>
<form action='example4_16_pane.jsp' method='post' >
留言者:<input  type='text' name='peopleName' size = 40/>
<br>标题:<input  type='text' name='title' size = 42/>
<br>留言:<br>
<textArea name='contents' id='textStyle' rows='10' cols=36 wrap='physical'>
</textArea>
<br><input type='submit' id='textStyle' value='提交留言' name='submit'/>
</form>
<a href='example4_16_show.jsp'>查看留言</a>
<a href='example4_16_delete.jsp'>删除留言</a>
</body></HTML>

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %>
<%@ page import="java.util.Enumeration" %>
<HTML><body bgcolor = pink> 
<p style="font-family:宋体;font-size:18;color:blue">
管理员删除留言.
<form action="" method=post >
输入密码:<input type="password" name="password"  size=12 /><br>
输入留言序号:<input type="text" name="index" size=6 /> 
<br><input type="submit" name="submit"  value="删除"/>
</form> 
<%  String password=request.getParameter("password");
    String index=request.getParameter("index");
    if(password == null ) password = "";
    if(index == null ) index = "";
    if(password.equals("123456")){
      Enumeration<String> e = application.getAttributeNames();
      while(e.hasMoreElements()) {
        String key  = e.nextElement();
        if(key.equals(index)){
           application.removeAttribute(key);
           out.print("<br>删除了第"+index+"条留言<br>");
        }
      }
    } 
%>
<a href="example4_16.jsp" >返回留言页面</a> <br>
<a href="example4_16_show.jsp">查看留言板</a>
</p></body></HTML>
<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %>
<%@ page import="java.time.LocalDateTime" %>
<%@ page import="java.util.Stack" %>
<HTML><body>
<%!
    Stack<Integer> maxAmount = null;  //存放留言序号。
    //向application添加对象的synchronized方法
    synchronized void addMess(ServletContext application,StringBuffer mess){    
        int index = -1;//留言序号
        if(!maxAmount.empty()){
          index = maxAmount.pop(); 
          mess.insert(0,"No."+index+".");
          application.setAttribute(""+index,new String(mess));
        }
    }
%>
<%  
   if(maxAmount == null){
       maxAmount = new Stack<Integer>();//最多可以有999999条留言
       for(int i=999999;i>=1;i--){
          maxAmount.push(i);
       }
    }
    boolean isSave = true;
    request.setCharacterEncoding("utf-8");
    String peopleName=request.getParameter("peopleName");
    String title=request.getParameter("title");
    String contents=request.getParameter("contents");
    if(peopleName.length()==0||title.length()==0||contents.length()==0){
       isSave = false;
       out.print("<h2>"+"请输入留言者,标题和内容");
    }
    if(isSave) {
      LocalDateTime dateTime = LocalDateTime.now();
      StringBuffer message = new StringBuffer();
      message.append("留言者:"+peopleName+"#");
      message.append("<br>留言标题《"+title+"》#");
      message.append("<br>留言内容:<br>"+contents+"#");
      String timeFormat= String.format("%tY年%<tm月%<td日,%<tH:%<tM:%<tS",dateTime);
      message.append("<br>留言时间<br>"+timeFormat+"#");
      if(maxAmount.empty()){
        out.print("<h2>"+"留言版已满,无法再留言"+"</h2");
      }
      else {
        addMess(application,message);//信息存放到appication(留言板角色)。
      }
    }
%>
<br><a href="example4_16.jsp">返回留言页面</a><br>
<a href="example4_16_show.jsp">查看留言板</a>
</body></HTML>

<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %>
<%@ page import="java.util.Enumeration" %>
<HTML><body bgcolor = cyan> 
<p style="font-family:宋体;font-size:14;color:black">
<a href="example4_16.jsp" >返回留言页面 </a><br><br>
<% 
    Enumeration<String> e = application.getAttributeNames();
    while(e.hasMoreElements()) {
        String key  = e.nextElement();
        String regex ="[1-9][0-9]*";//匹配用户的关键字
        if(key.matches(regex)){
           String message=(String)application.getAttribute(key);
           String [] mess =message.split("#");
           out.print(mess[0]); //留言者和序号。
           out.print(mess[1]); //标题。
           out.print(mess[2]); //留言内容。
           out.print(mess[3]); //留言时间。
           out.print("<br>-----------------------------------<br>");
        }
    } 
%>
</p></body></HTML>

运行结果:

 


总结

以上就是今天要讲的内容。针对jsp的四个重要的内置对象进行的分析。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值