请选择 进入手机版 | 继续访问电脑版

饕餮源码网,商业源码,游戏源码下载,discuz插件,棋牌源码下载,精品源码论坛

 找回密码
 立即注册
查看: 102|回复: 9

[ASP编程] javascript asp教程服务器对象

[复制链接]

7万

主题

8万

帖子

32万

积分

论坛元老

Rank: 8Rank: 8

积分
329525
发表于 2007-3-2 00:00:00 | 显示全部楼层 |阅读模式

Overview:

The Server Object has seven (7) Methods, one (1) Property, zero (0) Events, and zero (0) Collections.

List of Methods:

Server Methods
CreateObject( ) Server.CreateObject("ADODB.Recordset")
Create an instance of an Object
Execute( ) Server.Execute("fileName.asp")
Executes an outside file (effect is similar to SSI)
GetLastError( ) Server.GetLastError()
Returns location and description of the last ASP error
HTMLEncode( ) Server.HTMLEncode("some String")
Encodes string to HTML characters
MapPath( ) Server.MapPath("\\virtualFolder")
Converts virtual path to physical path
Transfer( ) Server.Transfer("fileName.asp")
Transfers execution out of one page and into another
URLEncode( ) Server.URLEncode("some String")
Encodes string to URL standards

Below is the script for Lesson 14.

<%@LANGUAGE="JavaScript"%>
<HTML>
<BODY>
<%=Server.URLEncode("Hello, this string is URL Encoded!")%>
<BR><BR>
Now let's see a reprint of Script14a.asp.
I did not type it manually. Instead, I let
Server.CreateObject( ) do all the work.<BR>
<STRONG>
<%
Server.ScriptTimeout=10
var ASPScriptObject = Server.CreateObject("Scripting.FileSystemObject");
var myPath=Server.MapPath("\\") + "\\Section04\\script14a.asp"
var AspScript = ASPScriptObject.OpenTextFile(myPath);
var outputScript="";

while(!AspScript.AtEndOfStream)
	{
	outputScript += AspScript.ReadLine() + "\r";
	}

outputScript = new String(outputScript);
outputScript=Server.HTMLEncode(outputScript)
AspScript.Close();
outputScript = "<PRE>" + outputScript + "</PRE>";
Response.Write(outputScript)
%>
</STRONG>
</BODY>
</HTML>

Click Here to run the script in a new window.

I demonstrated four methods in the script14.asp. We'll take them from top to bottom.

Explaining the Script:

Server.URLEncode() does exactly what you think it does. It takes a string and encodes it to RFC 1738 standards. That's more than you ever wanted to know about Server.URLEncode(), isn't it?

Next we have Server.CreateObject(). In this case I created an instance of the FileSystem Object. The most common objects that you will instanciate are ADODB.Recordset, Scripting.FileSystemObject, Scripting.Dictionary, MSWC.AdRotator, MSWC.BrowserType, MSWC.NextLink, and MSWC.ContentRotator. There are many good resources on all of these created Objects. Most of them are beyond the scope of this web site.

Next on the list is Server.MapPath(). Looking back at script14.asp, do you see the double slashes (\\) in the MapPath argument? That's not an accident. We have to use escape characters in JavaScript.

The last Method I demonstrate is Server.HTMLEncode(). It converts HTML flags into non-HTML equivalents.

The Lone Property:

Server has one property: ScriptTimeout. It sets the maximum number of seconds allowable for script execution. If the script execution exceeds that time, then it times out. The user gets an ugly message but at least the Web Server can quit executing your darned greedy script and go about other business.

回复

使用道具 举报

0

主题

9779

帖子

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2022-10-29 01:25:30 | 显示全部楼层
笑纳了老板
回复 支持 反对

使用道具 举报

3

主题

9746

帖子

301

积分

中级会员

Rank: 3Rank: 3

积分
301
发表于 2022-11-2 22:56:35 | 显示全部楼层
飞飞飞飞飞飞飞飞飞飞飞飞飞
回复 支持 反对

使用道具 举报

12

主题

9944

帖子

431

积分

中级会员

Rank: 3Rank: 3

积分
431
发表于 2022-11-30 12:58:01 | 显示全部楼层
66666666666
回复 支持 反对

使用道具 举报

0

主题

9519

帖子

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2022-12-1 19:46:08 | 显示全部楼层
不错的源码论坛
回复 支持 反对

使用道具 举报

0

主题

9611

帖子

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-1-2 02:51:39 | 显示全部楼层
问问问企鹅哇哇哇哇哇
回复 支持 反对

使用道具 举报

匿名  发表于 2023-1-2 04:31:30

does insurance cover cialis

cost of cialis
<a href="https://citrostimol.com/">where can i buy cialis</a>
回复 支持 反对

使用道具

匿名  发表于 2023-1-2 04:32:03

cialis generics

z80vh ·±нУЪ 2023-1-2 02:51
ОКОКОКЖумНЫНЫНЫНЫНЫ

cialis vs viagra vs levitra
<a href="https://citrostimol.com/">viagra versus cialis</a>
回复 支持 反对

使用道具

匿名  发表于 2023-1-2 04:32:38

how to get cialis

buy cialis online without prescription
<a href="https://citrostimol.com/">cheap cialis</a>
回复 支持 反对

使用道具

2

主题

8963

帖子

73

积分

注册会员

Rank: 2

积分
73
发表于 2023-2-3 11:45:09 | 显示全部楼层
先把创新班才能下班才能下班
回复 支持 反对

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

手机版|小黑屋|网站地图|饕餮源码网 ( 海外版 )

GMT+8, 2023-3-26 16:49 , Processed in 0.079930 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表