JSP内置对象实验.docVIP

  • 174
  • 0
  • 约4千字
  • 约 5页
  • 2017-07-27 发布于重庆
  • 举报
JSP内置对象实验

JSP内置对象实验 一、实验目的 1.掌握 JSP 内置对象:request、response、session、application、out等。 2.掌握 JSP 内置对象的使用方法。 二:实验 1:编写一个简单的留言薄,写入留言提交后显示 输出内容: 2:设计一添加、删除 session 变量及其值的程序 %@ page language=java contentType=text/html; charset=UTF-8 pageEncoding=UTF-8 import=java.util.*% !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN /TR/html4/loose.dtd html head meta http-equiv=Content-Type content=text/html; charset=UTF-8 titleInsert title here/title /head body center font size=5 color=#DB1260 管理Session变量 /font BR HR BR % if (request.getParameter(AddValue) != null) { session.setAttribute(request.getParameter(NameField), request.getParameter(ValueField)); } else if (request.getParameter(DeleteValue) != null) { session.removeAttribute(request.getParameter(NameField)); } % center table border=1 cellspacing=2 cellpadding=5 width=400 bgcolor=#EEEEEE th colspan=2Session/th tr tdB变量名/B/td tdB变量值/B/td /tr % Enumeration sessionNames = session.getAttributeNames(); String name; while (sessionNames.hasMoreElements()) { name = (String) sessionNames.nextElement(); % tr td%=name%/td td%=(String) session.getAttribute(name)%/td /tr % } // end of while loop for session names % /table /center p form method=post name=SessionTest action= center table border=0 cellspacing=2 cellpadding=5 width=400 th变量名/th th变量值/th tr tdinput type=text name=NameField/td tdinput type=text name=ValueField/td /tr tr td colspan=2 align=centerinput type=submit value=添加 name=AddValue input type=submit value=删除 name=DeleteValue/td /tr /table /center /form /center /body /html 3:使用application对象编写一个网页计数器 4:编写一个页面计数器,刷新不增加计数 提示: 1:使用cookie:服务器上的文件保存了访问次数用户访问后cookie并更新访问次数文件。刷新不增加次数。%@ page language=java contentType=text/html; charset=utf-8 pageEncoding=utf-8% !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN /TR

文档评论(0)

1亿VIP精品文档

相关文档