javascript asp教程服务器对象_ASP基础

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 ObjectExecute( )
Server.Execute("fileName.asp")
Executes an outside file (effect is similar to SSI)GetLastError( )
Server.GetLastError()
Returns location and description of the last ASP errorHTMLEncode( )
Server.HTMLEncode("some String")
Encodes string to HTML charactersMapPath( )
Server.MapPath("\\virtualFolder")
Converts virtual path to physical pathTransfer( )
Server.Transfer("fileName.asp")
Transfers execution out of one page and into anotherURLEncode( )
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.

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索javascript
javascript服务器端、javascript 服务器、javascript写服务器端、开源javascript服务器、javascript 对象,以便于您获取更多的相关知识。

时间: 2024-08-28 12:48:28

javascript asp教程服务器对象_ASP基础的相关文章

javascript asp教程错误处理_ASP基础

The ASPError Object has zero (0) Methods, nine (9) Properties, zero (0) Events, and zero (0) Collections. AspCode AspDescription Category Column Description File Line Number Source The way you access the ASPError Properties is with a Server Method. Y

javascript asp教程 日期相关_ASP基础

JavaScript is loosely typed. Database files are not. If you put text into a Boolean database column or a Boolean value into a date/time column, then you will get an error. For the most part this is not a problem, except for date/time. It does not cor

javascript asp教程Recordset记录_ASP基础

Recordset is another created/instanciated Object. It is a collection of data taken from a database. Recordset has 26 properties, 25 methods, 11 events, and two (2) collections. The vast majority of Recordset is beyond the scope of this web site. Quic

javascript asp教程创建数据库连接_ASP基础

While this section is devoted to ASP database utilization, it very important to remember that this web site is not intended to be a thorough ASP resource. Remember, the focus of this site is strictly limited to how to use JavaScript as your primary s

javascript asp教程服务器对象

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( ) Ser

javascript asp教程More About Recordsets_ASP基础

Below we will attempt to access data from a database without knowing the column names. Clearly the best way to utilize data in your database is to keep track of your schema. Schema is the layout of data in your database. The concept is well beyond th

javascript asp教程第九课--cookies_ASP基础

Response Cookies in General: We'll start with the Response Cookies collection. I don't think it could be any easier. You simply put the name of the cookie in the argument. The corresponding value is a string. The only time it gets complicated is when

javascript asp教程添加和修改_ASP基础

The Connection Execute(): If you want to retrieve data from a database then you have no choice but to use a Recordset. However, for the purposes of adding, updating, and deleting data you don't necessarily have to have a Recordset. It's up to you. Fo

详细讲解ASP脚本循环语句_ASP基础

如果有人告诉你学习 ASP 不需要任何编程知识,那么他错了:如果我告诉你学习 ASP 必须掌握一门编程语言,那么我错了.ASP 动态服务器页面环境的特点就在于它是通过一种或几种脚本语言而写成的,脚本语言可以看作是编程语言的简化版,它易于学习和掌握,这给广大动态网站的设计者们提供了相当大的便利.可以这么说 : 脚本语言运用的得当与否直接关系到 ASP 应用程序的优与劣.继上一篇我们学习了脚本语言 VBScript 的函数和条件语句后,今天我们继续来看看 VBScript 中的循环语句.   循环语