javascriptasp教程服务器对象
Overview:
TheServerObjecthasseven(7)Methods,one(1)Property,zero(0)Events,andzero(0)Collections.
ListofMethods:
CreateaninstanceofanObject
Executesanoutsidefile(effectissimilartoSSI)
ReturnslocationanddescriptionofthelastASPerror
EncodesstringtoHTMLcharacters
Convertsvirtualpathtophysicalpath
Transfersexecutionoutofonepageandintoanother
EncodesstringtoURLstandards
BelowisthescriptforLesson14.
<%@LANGUAGE="JavaScript"%> <HTML> <BODY> <%=Server.URLEncode("Hello,thisstringisURLEncoded!")%> <BR><BR> Nowlet"sseeareprintofScript14a.asp. Ididnottypeitmanually.Instead,Ilet Server.CreateObject()doallthework.<BR> <STRONG> <% Server.ScriptTimeout=10 varASPScriptObject=Server.CreateObject("Scripting.FileSystemObject"); varmyPath=Server.MapPath("\\")+"\\Section04\\script14a.asp" varAspScript=ASPScriptObject.OpenTextFile(myPath); varoutputScript=""; while(!AspScript.AtEndOfStream) { outputScript+=AspScript.ReadLine()+"\r"; } outputScript=newString(outputScript); outputScript=Server.HTMLEncode(outputScript) AspScript.Close(); outputScript="<PRE>"+outputScript+"</PRE>"; Response.Write(outputScript) %> </STRONG> </BODY> </HTML>
ClickHeretorunthescriptinanewwindow.
Idemonstratedfourmethodsinthescript14.asp.We"lltakethemfromtoptobottom.
ExplainingtheScript:
Server.URLEncode()doesexactlywhatyouthinkitdoes.IttakesastringandencodesittoRFC1738standards.That"smorethanyoueverwantedtoknowaboutServer.URLEncode(),isn"tit?
NextwehaveServer.CreateObject().InthiscaseIcreatedaninstanceoftheFileSystemObject.ThemostcommonobjectsthatyouwillinstanciateareADODB.Recordset,Scripting.FileSystemObject,Scripting.Dictionary,MSWC.AdRotator,MSWC.BrowserType,MSWC.NextLink,andMSWC.ContentRotator.TherearemanygoodresourcesonallofthesecreatedObjects.Mostofthemarebeyondthescopeofthiswebsite.
NextonthelistisServer.MapPath().Lookingbackatscript14.asp,doyouseethedoubleslashes(\\)intheMapPathargument?That"snotanaccident.WehavetouseescapecharactersinJavaScript.
ThelastMethodIdemonstrateisServer.HTMLEncode().ItconvertsHTMLflagsintonon-HTMLequivalents.
TheLoneProperty:
Serverhasoneproperty:ScriptTimeout.Itsetsthemaximumnumberofsecondsallowableforscriptexecution.Ifthescriptexecutionexceedsthattime,thenittimesout.TheusergetsanuglymessagebutatleasttheWebServercanquitexecutingyourdarnedgreedyscriptandgoaboutotherbusiness.
相关文章
- Pycharm远程连接服务器(windows下远程修改服务器代码)[通俗易懂]
- 腾讯云服务器镜像市场快速搭建WordPress博客网站教程
- [保姆级教程]SRS直播服务器搭建兼ffmpeg推流+obs在线直播+集成
- Teamspeak3 服务器搭建教程
- 【教程】利用Haproxy解决SMTP发信暴露服务器源IP的方法
- Linux+MCSM9+Docker 搭建我的世界Java版服务器,MC开服教程
- 腾讯云服务器安全组配置教程
- 【教程】如何在服务器上部署豆瓣小组抢沙发聊天机器人
- 香港服务器IIS 8.5设置404错误页教程
- 云服务器怎么清理IIS日志教程
- Linux服务器VPS的Windows DD包详细的制作教程
- oracle远程连接服务器数据库图文教程
- MySQL注册服务器:简单、安全、高效(mysql注册服务器)
- 搭建Linux服务器:最佳实践指南(怎么搭建linux服务器)
- Oracle服务器每日日志监控及分析(oracle服务日志)
- Linux服务器让Mac用户体验极致简单体验(linux服务器mac)
- XML 服务器
- Linux服务器轻松掌控:控制面板的管理实用技巧(linux服务器控制面板)
- 利用Azure 助力MySQL 服务器升级(azure mysql)
- MySQL上传服务器时出现乱码问题原因和解决方法(mysql上传服务器乱码)
- 新增服务器实现Redis集群的扩容(redis集群添加服务器)
- 第2季度研报:AMD市场份额创14年来新高 服务器和移动业务表现亮眼
- JavaSocket编程(五)简单的WEB服务器
- 显示服务器时间的在线时钟代码简单