您现在的位置是:首页 > 数码 > 

20181910104 田鑫萌

2025-07-21 08:28:50
104 田鑫萌 一、request对象 通过该对象获取用户提交的信息 request.getParameter(); 该对象包含了当前用户请求的上下文,包括表单信息,传递的参数信息等 <%@ page language=java contentType=text/html; charse

20181910104 田鑫萌

一、request对象

通过该对象获取用户提交的信息 request.getParameter();
该对象包含了当前用户请求的上下文,包括表单信息,传递的参数信息等

<%@ page language=java contentType=text/html; charset=UTF-8pageEncoding=UTF-8%><!DOCTYPE html PUBLIC -//WC//DTD HTML 4.01 Transitional//E .dtd><html><head><meta http-equiv=Content-Type content=text/html; charset=UTF-8><title>Insert title here</title></head>
<body>
<form action=request-receiver.jsp>姓名:<input  type=text name=user/><br/>密码:<input  type=password name=pwd/><br/><input type=submit name=登陆/></form></body></html>
二、session对象:会话对象

    当客户端第一次访问服务器的页面时,web服务器会自动为该客户端创建一个session对象并分配一个唯一的id号
常常用它来在多个页面间共享数据,如我们课可以把访问权限放在会话中,以免 多次连接数据库

<html>
<head><base href=<%=basePath%>><title>session1</title><meta http-equiv=pragma content=no-cache><meta http-equiv=cache-control content=no-cache><meta http-equiv=expires content=0><meta http-equiv=keywords content=keyword1,keyword2,keyword><meta http-equiv=description content=This is my page><link rel=stylesheet type=text/css href=css/></head><body>
<form id=form1 name=form1 method=post action=session2.jsp><div align=center><table width=40% border=0><tr><td width=6%><div align=center>您的名字是:</div></td><td width=64%><label><div align=center><input type=text name=name /></div></label></td></tr><tr><td colspan=2><label><div align=center><input type=submit name=Submit value=提交 /></div></label></td></tr></table></div>
</form>
</body>
</html>
三、.application对象

该对象的父类为:javax.servlet.ServletSontext类。
作用域、声明周期:
在服务器打开时创建,服务器关闭时销毁,对应用程序来讲是唯一的,因此application也是session共享的

<%@ page contentType=text/html;charset=UTF-8 language=java %>
<%Integer count=(Integer) application.getAttribute(count);if(count==null){count=1;}else{count;}application.setAttribute(count,count);
%>
<html><head><title>application</title></head><body><center>欢迎访问本网站,您是第<%=count%>位访问客户!</center></body>
</html>
四、respe对象:相应对象

其父类为javax.servlet.ServletRequest,包含了当前web服务器响应的上下文。该对象常常被用来完成页面的跳转、页面的自动刷新、页面的自动跳转、禁用缓存等功

​​​​​ <%@page language=java contentType=text/html; charset=UTF-8pageEncoding=UTF-8%><!DOCTYPE html PUBLIC -//WC//DTD HTML 4.01 Transitional//E .dtd><html><head><meta http-equiv=Content-Type content=text/html; charset=utf-8><title>Insert title here</title></head><body><form action=index.jspmethod=post>用户名:<input type=text name=user/></br/>密  码:<input type=password name=pwd/></br/><input  type=submit name=登陆/></form></body></html>​​​​
​
五、out对象

   输出流对象。

<%@ page contentType=text/html;charset=UTF-8 language=java %>
<html>
<head><title>out</title>
</head>
<body>
<center><hr><h4>表格如下</h4><%out.println(<table border=	2	>);out.println(<tr>);out.println(<td width=	60	>姓名</td>);out.println(<td width=	40	>性别</td>);out.println(<td width=	80	>姓出生年月</td>);out.println(<td width=	60	>城市</td>);out.println(</tr>);out.println(<tr>);out.println(<td width=	60	>txm</td>);out.println(<td width=	60	>famale</td>);out.println(<td width=	60	>2000.6</td>);out.println(<td width=	60	>China</td>);out.println(</tr>);out.println(</table>);%>
</center>
</body>
</html>
 六、config【ServletConfig】

  获取servlet配置信息 

 
<%@ page language=java import=java.util.* pageEncoding=UTF-8%>
<!DOCTYPE HTML PUBLIC -//WC//DTD HTML 4.01 Transitional//E>
<html>
<head><title>config</title>
</head><body>
<%String url = config.getInitParameter(url);String str = ();out.print(page对象的initParameter方法:url</br>);out.print(page对象的toString方法:str);
%>
</body>
</html>
七、page

  在编译的servlet中,Object page = this;page对象表示当前一个JSP页面,可以理解为一个对象本身

<%@ page contentType=text/html;charset=UTF-8 language=java import=java.util.* %>
<html><head><title>page</title></head><body><center><%int code=page.hashCode();String str=();out.println(page对象的hash码code&nbsp;&nbsp;</br>);out.println(page对象的值:str);%></center></body>
</html>

八、exception对象
<%@ page contentType=textml;charset=UTF-8 language=java errorPage=error.jsp %>
<html>
<head><title>exception</title>
</head>
<body><%int a=8;int b=0;int c=a/b;%></body>
</html>
<%@ page contentType=text/html;charset=UTF-8 language=java
pageEncoding=UTF-8 isErrorPage=true%>
<html>
<head><title>exception对象</title>
</head>
<body>
<hr>
异常类型:<%=exception.getClass()%><br/><br/>
异常信息:<%=exception.getMessage()%>
<hr/>
</body>
</html>

 

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/shuma/794033.html

相关标签:无
上传时间: 2024-01-09 22:42:18
留言与评论(共有 16 条评论)
本站网友 28天后
11分钟前 发表
禁用缓存等功 ​​​​​ <%@page language=java contentType=text/html; charset=UTF-8pageEncoding=UTF-8%><!DOCTYPE html PUBLIC -//WC//DTD HTML 4.01 Transitional//E .dtd><html><head><meta http-equiv=Content-Type content=text/html; charset=utf-8><title>Insert title here</title></head><body><form action=index.jspmethod=post>用户名
本站网友 换偶
4分钟前 发表
count); %> <html><head><title>application</title></head><body><center>欢迎访问本网站,您是第<%=count%>位访问客户!</center></body> </html> 四
本站网友 分利网
7分钟前 发表
该对象常常被用来完成页面的跳转
本站网友 如何发私信
19分钟前 发表
作用域
本站网友 太原商铺转让
27分钟前 发表
request对象 通过该对象获取用户提交的信息 request.getParameter(); 该对象包含了当前用户请求的上下文,包括表单信息,传递的参数信息等 <%@ page language=java contentType=text/html; charset=UTF-8pageEncoding=UTF-8%><!DOCTYPE html PUBLIC -//WC//DTD HTML 4.01 Transitional//E .dtd><html><head><meta http-equiv=Content-Type content=text/html; charset=UTF-8><title>Insert title here</title></head> <body> <form action=request-receiver.jsp>姓名
本站网友 昆明癫病军海电话
19分钟前 发表
.application对象 该对象的父类为:javax.servlet.ServletSontext类
本站网友 上海九院官网
11分钟前 发表
out对象    输出流对象
本站网友 wordpress空间
6分钟前 发表
respe对象:相应对象 其父类为javax.servlet.ServletRequest
本站网友 seed3
27分钟前 发表
<input type=password name=pwd/></br/><input type=submit name=登陆/></form></body></html>​​​​ ​ 五
本站网友 深圳住房公积金查询
21分钟前 发表
page   在编译的servlet中,Object page = this;page对象表示当前一个JSP页面,可以理解为一个对象本身 <%@ page contentType=text/html;charset=UTF-8 language=java import=java.util.* %> <html><head><title>page</title></head><body><center><%int code=page.hashCode();String str=();out.println(page对象的hash码code&nbsp;&nbsp;</br>);out.println(page对象的值
本站网友 杀猪饭
30分钟前 发表
作用域
本站网友 男人怎样玩女人
25分钟前 发表
<%@ page contentType=text/html;charset=UTF-8 language=java %> <html> <head><title>out</title> </head> <body> <center><hr><h4>表格如下</h4><%out.println(<table border= 2 >);out.println(<tr>);out.println(<td width= 60 >姓名</td>);out.println(<td width= 40 >性别</td>);out.println(<td width= 80 >姓出生年月</td>);out.println(<td width= 60 >城市</td>);out.println(</tr>);out.println(<tr>);out.println(<td width= 60 >txm</td>);out.println(<td width= 60 >famale</td>);out.println(<td width= 60 >2000.6</td>);out.println(<td width= 60 >China</td>);out.println(</tr>);out.println(</table>);%> </center> </body> </html>  六
本站网友 钓鱼台美高梅
29分钟前 发表
该对象常常被用来完成页面的跳转
本站网友 上海人民
29分钟前 发表
<input type=text name=user/></br/>密 码
本站网友 上海燕南园
17分钟前 发表
页面的自动刷新