ASP内置对象之Request对象
来源:互联网 发布:python频域转时域 编辑:程序博客网 时间:2024/05/20 06:39
一、功能:浏览器向服务器发出请求,即接受从客户端传来的数据
二、集合(Collection)
Request对象把客户端信息保存在几个集合中,供ASP应用使用。
使用格式:Request.Collection("membername")
常用的集合有:
1.QueryString集合
当HTML表单中的method="get"时,可以用Request.QueryString来获取表单提交的信息
格式:Request.QueryString(Varible)[(Index).Count]
注:
1>QueryString集合是查询字符串的所有值的集合。
2>Varible是在查询字符串某一变量的名称。
3>当某一变量具有多于一个值时,使用Index。
4>当某一参数具有多值时,Count指明值的个数。
例:fillinfo_get.html
------------------------------------fillinfo_get.html-----------------------------
<html>
<head>
<title>QueryString接受HTML表单使用get方法传递的数据</title>
</head>
<body>
<font color="#0000ff" >请填写如下信息:</font><br>
<div align="center">
<form name="info" action="showinfo_get.asp" method="get">
姓名:<input type="text" name="name" size=19><br>
密码:<input type="password" name="pwd"><br>
<input type="submit" name="ok" value="确定">
<input type="reset" name="reset" value="重置"><br>
</form>
</div>
</body>
</html>
------------------------------------fillinfo_get.html--------------------------------------
showinfo_get.asp:
------------------------------------showinfo_get.asp-------------------------------------
<% @ language="JavaScript" %>
<html>
<head>
<title>显示信息</title>
</head>
<body>
<%
var myname=Request.QueryString("name"), //name为姓名文本框输入的内容
mypwd =Request.QueryString("pwd"); //pwd 为密码框输入的的内容
Response.Write("姓名:"+myname+"<br>"+"密码:"+mypwd+"<br>");
%>
</body>
</html>
------------------------------------showinfo_get.asp-------------------------------------
2.Form集合
当HTML表单中method="post"时,可以用Request.Form来获取HTML表单提交的信息。
格式:Request.Form(Parameter)[(Index).Count]
注:
1>Request.Form获取的是一个集合(collection);
2>Request.Form 集合有个参数Parameter,对应HTML表单控件的name值;
格式:Request.Form(Parameter)
Parameter是在HTML表单中某一元素的名称
3.当某一参数具有不止一个值(比如,当在<SELECT>中使用MULTIPLE属性时)时,使用Index。
格式:Request.Form(Parameter)(index)
index 从1开始计数。
当某一参数具有多值时,Count指明多值的个数。
格式:Request.Form(Parameter).count
例:fillinfo_post.html
------------------------------------fillinfo_post.html-------------------------------------
<html>
<head>
<title>method=post</title>
</head>
<body>
<form name="chose" action="showinfo_post.asp" method="post">
<h3>请选择你喜欢的港剧</h3>
<input type="checkbox" name="gj" value="天龙八部">天龙八部<br>
<input type="checkbox" name="gj" value="创世纪" >创世纪<br>
<input type="checkbox" name="gj" value="射雕英雄传">射雕英雄传<br>
<input type="checkbox" name="gj" value="神雕侠侣">神雕侠侣<br>
<input type="submit" name="ok" value="确定">
<input type="reset" name="reset" value="重置"><br>
</form>
</body>
</html>
------------------------------------fillinfo_post.html-------------------------------------
showinfo_post.asp
------------------------------------showinfo_post.asp-------------------------------------
<%@ language="JavaScript" %>
<html>
<head>
<title>你最喜欢的港剧</title>
</head>
<body>
<%
Response.Write("你最喜欢的港剧有:<br>");
var num=Request.Form("gj").count;
Response.Write("你选中了"+num+"个:<br>");
Response.Write("<p>"+Request.Form("gj")+"<br></p>");
for(var index=1;index<=num;index++)
{
Response.Write(Request.Form("gj")(index)+"<br>");
}
%>
</body>
</html>
------------------------------------showinfo_post.asp-------------------------------------
3.ServerVariable集合
ServerVariables集合用于取回服务器变量的值。
语法:Request.ServerVariables(server_variable)
server_variable:要取回的服务器变量的名称。
例:testSV.asp
-----------------------------------------testSV.asp----------------------------------------
<% @language="JavaScript" %>
<html>
<head>
<title>测试几个简单的Request.ServerVariables集合变量</title>
</head>
<body>
<p><b>你的IP地址是:</b>
<%
var ip=Request.ServerVariables("REMOTE_ADDR");
Response.Write(ip+"<br>");
%>
</p><hr>
<p><b>你的主机名是:</b>
<%
var hostname=Request.ServerVariables("REMOTE_HOST");
Response.Write(hostname+"<br>");
%>
</p><hr>
<p><b>服务器主机名是:</b>
<%
var servername=Request.ServerVariables("SERVER_NAME");
Response.Write(servername+"<br>");
%>
</p><hr>
<p><b>服务器端口是:</b>
<%
var serverport=Request.ServerVariables("SERVER_PORT");
Response.Write(serverport+"<br>");
%>
</p><hr>
<body>
</html>
-----------------------------------------testSV.asp----------------------------------------
4.Cookies
这个和后面的Response对象的Cookies一起学习
- ASP内置对象详解之Request对象
- ASP内置对象之Request对象
- 重温ASP.NET内置对象之Request
- 内置对象之request对象
- ASP.NET的内置对象:Request对象
- ASP.NET内置对象之Respone和Request
- JSP内置对象之request
- jsp内置对象之request
- jsp内置对象之request
- java内置对象之request
- JSP内置对象之request
- .NET内置对象之Request对象
- jsp内置对象之request对象
- jsp内置对象之request对象
- ASP内置对象Request和Response详解
- ASP内置对象Request和Response详解
- ASP内置对象Request和Response详解
- ASP.NET的内置对象之一 Request
- 青春 -- 塞缪尔厄尔曼
- 安装alexa工具条报毒
- 安装alexa工具条报毒
- Oracle内建函数(greatest, least, to_single_byte)
- CMD命令集合
- ASP内置对象之Request对象
- 毕 业 设 计 论 文 ......
- 第三章 程序的流程控制(四)
- 用户、用户组、角色的区别和联系
- ZOJ 1918 Ferry Loading II
- 《功夫之王》票房喜人,全面超过《集结号》
- 我们还差多少年?
- 农民企业家拿钱去炒楼导致猪价上涨
- (转)2.2 深入信号和槽