ASP Getting Started Tutorial: ASP Server Object Simple

Source: Internet
Author: User
Tags access properties readline

ASP Getting Started Tutorial: ASP Server Object Simple

The ASP server object is used to access properties and methods on the server.

Okay, let's take a look at an example here:

<body>

<%
Set fs = Server.CreateObject ("Scripting.FileSystemObject")
Set rs = fs. GetFile (Server.MapPath ("demo_lastmodified.asp"))
Modified = Rs. DateLastModified
%>
This file is last modified on: <%response.write (modified)
Set rs = Nothing
Set fs = Nothing
%>

</body>

This file is last modified on:01/10/2007 03:40:59

Instance two.

<body>

<%
Set FS = Server.CreateObject ("Scripting.FileSystemObject")
Set RS = FS. OpenTextFile (Server.MapPath ("text") & "TextFile.txt", 1)
While not Rs. AtEndOfStream
Response.Write RS. ReadLine
Response.Write ("<br/>")
Wend
%>

<p>
<a href= "Text/textfile.txt" ></a>
</p>
Output results.

Hello World Line 1
Hello World Line 2
Hello World Line 3

Instance three.

<%
Set fs=server.createobject ("Scripting.FileSystemObject")
Set Rs=fs. OpenTextFile (Server.MapPath ("Counter.txt"), 1, False)
Fcount=rs. ReadLine
Rs. Close

Fcount=fcount+1

' This code was disabled due to the Write access security on our server:
' Set rs=fs. OpenTextFile (Server.MapPath ("Counter.txt"), 2, False)
' RS. Write Fcount
' RS. Close

Set rs=nothing
Set fs=nothing

%>
<body>
<p>
This page has been the visited <%=fcount%> times.
</p>
</body>
Output results.

This page has been the visited 12345 times.

Reprint please indicate from http://www.111cn.net/asp/asp.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.