泰州电脑学习网   网上汇款免手续费, 收货满意后卖家才能拿钱,货款都安全
收藏本站
  当前位置 : 首页 >> 网站建设 >> asp专栏 >>
ASP基础教程之实例学习ASP Response 对象
来源:本站 日期:2007-7-7 点击:
Cookies设置cookie的值。假如cookie不存在,就创建cookie,然后设置指定的值。

属性

Buffer规定是否缓冲页面的输出CacheControl设置代理服务器是否可以缓冲由ASP产生的输出。Charset将字符集的名称追加到Response对象中的content-type头部。ContentType设置Response对象的HTTP内容类型。Expires设置页面在失效前的浏览器缓存时间(分钟)ExpiresAbsolute设置页面缓存失效的日期和时间。IsClientConnected指示客户端是否已从服务器断开。Pics向response头部的PICS标志追加值。Status规定由服务器返回的状态行的值。

方法

AddHeader向HTTP response添加新的HTTP头部和值AppendToLog向服务器记录项目(server log entry)的末端添加字符串BinaryWrite在没有任何字符转换的情况下直接向输出写数据Clear清楚已缓冲的HTML输出End停止处理脚本,并返回当前的结果Flush立即发送已缓冲的HTML输出Redirect把用户重定向到另一个URLWrite向输出写指定的字符串


责任编辑:不详


ASP Response 对象用于从服务器向用户发送输出的结果。

实例

使用ASP写文本

本例演示如何使用ASP来写文本。

<html>
<body>
<%
response.write("Hello World!")
%>
</body>
</html>

在ASP中使用HTML标签格式化文本

本例演示如何使用ASP将文本和HTML标签结合起来。

<html>
<body>
<%
response.write("<h2>You can use HTML tags to format the text!</h2>")
%>
<%
response.write("<p style='color:#0000ff'>This text is styled with the style attribute!</p>")
%>
</body>
</html>

将用户重定向至不同的URL

本例演示如何将用户重定向至另一个的URL。

<%
if Request.Form("select")<>"" then
       Response.Redirect(Request.Form("select"))
end if
%>
<html>
<body>
<form action="/example/aspe/demo_aspe_redirect.asp" method="post">
<input type="radio" name="select"
value="/example/aspe/demo_aspe_server.asp">
Server Example<br>
<input type="radio" name="select"
value="/example/aspe/demo_aspe_text.asp">
Text Example<br><br>
<input type="submit" value="Go!">
</form>
</body>
</html>

显示随机的链接

本例演示一个超级链接,当您每次载入页面时,它将显示两个链接中的其中一个。

<html>
<body>
<%
randomize()
r=rnd()
if r>0.5 then
  response.write("<a href='http://webjx.com'>webjx.com</a>")
else
  response.write("<a href='http://www.webjx.com'>www.webjx.com</a>")
end if
%>
<p>
This example demonstrates a link, each time you load the page, it will display
one of two links: Webjx.com! OR www.webjx.com! There is a 50% chance for
each of them.
</p>
</body>
</html>

控制缓存

本例演示如何控制缓存。

<%
Response.Buffer=true
%>
<html>
<body>
<p>
This text will be sent to your browser when my response buffer is flushed.
</p>
<%
Response.Flush
%>
</body>
</html>

清空缓存

本例演示如何清空缓存。

<%
Response.Buffer=true
%>
<html>
<body>
<p>This is some text I want to send to the user.</p>
<p>No, I changed my mind. I want to clear the text.</p>
<%
Response.Clear
%>
</body>
</html>

在处理过程中终止脚本并返回结果

本例演示如何在处理过程中中断脚本的运行。

<html>
<body>
<p>I am writing some text. This text will never be<br>
<%
Response.End
%>
finished! It's too late to write more!</p>
</body>
</html>

设置在页面失效前把页面在浏览器中缓存多少分钟

本例演示如何规定页面在失效前在浏览器中的缓存时间。

<%Response.Expires=-1%>
<html>
<body>
<p>This page will be refreshed with each access!</p>
</body>
</html>

设置页面缓存在浏览器中的失效日期或时间

本例演示如何规定页面在浏览器中的缓存时间日期或时间

<%
Response.ExpiresAbsolute=#May 05,2001 05:30:30#
%>
<html>
<body>
<p>This page will expire on May 05, 2001 05:30:30!</p>
</body>
</html>

检查用户是否仍然与服务器相连

本例演示如何检查用户是否已与服务器断开。

<html>
<body>
<%
If Response.IsClientConnected=true then
Response.Write("The user is still connected!")
else
Response.Write("The user is not connected!")
end if
%>
</body>
</html>

设置内容类型

本例演示如何规定内容的类型。

<%
Response.ContentType="text/html"
%>
<html>
<body>
<p>This is some text</p>
</body>
</html>

设置字符集

本例演示如何规定字符集的名称。

<%
Response.Charset="ISO8859-1"
%>
<html>
<body>
<p>This is some text</p>
</body>
</html>

Response 对象

ASP Response 对象用于从服务器向用户发送输出的结果。它的集、属性和方法如下:

Collection描述
Property描述
Method描述
打印本文 关闭本页 返回页首
相关文章
·md5加密和解密 ·在电子商务中ASP实现购物车的方法
·ASP中access数据库的路径问题 ·一个登陆窗口的记数判断登录(有用哦),了...
·防止Access数据库被下载 ·用Asp隐藏文件路径,实现防盗链
·通过实例讲解来学习ASP中的函数 ·用ASP代码得到客户端IP和当前地址
·ASP教程:ASP分页列表生成静态页面的小程序 ·ASP读sql数据时出现乱码问题的解决方法
·网站安全知识 ASP网站黑客防范编程技巧 ·ASP和Access结合编写目录树的程序实例
·整理:防止Access数据库被下载的9种方法 ·ASP脚本语言的19个基本技巧使用
·推荐文章:ASP脚本程序的15种使用技巧 ·Cookie是什么?用法是怎样?与SESSION有什么...
  热点文章
·键盘操作大全
·如何重装xp系统图解
·神奇地加快XP宽带上...
·如何组装一台电脑
·电脑组装全教程
·五笔字型输入法
·让QQ永久在线——挂...
·bios设置图解教程
  推荐文章
·最新驱动下载
·什么是Google优化
·网站备案绕过手机验证...
·电脑无法启动的特殊故...
·启动“黑屏”故障检修...
·几种主板BIOS报警声音...
·网管维护局域网技巧大...
·网络经典命令行
  相关文章
网站首页 | 关于我们 | 在线学习 | 业务联系 | 版权声明 | 联系方式 | 留言/建议/投诉 | 技术交流
客服邮箱:web@0523pc.com  QQ:43957884
 版权所有、肆意抄袭、模仿必究 泰州电脑© 2004 苏ICP备07003435号