What is asp?
ASP is the abbreviation of Active Server Page, which means "Active Server Page". ASP is an application developed by Microsoft, not a CGI script. It can interact with databases and other programs, and is a simple and convenient programming tool. The web page file format of Asp is. ASP, now commonly used in various dynamic websites. ASP is a server-side scripting environment, which can be used to create and run dynamic Web pages or web applications. ASP web pages can contain HTML tags, plain text, script commands, com components and so on. With ASP, you can add interactive content (such as online forms) to web pages, and you can also create web applications that use HTML pages as user interfaces. Compared with HTML, ASP pages have the following characteristics:

(1) ASP can break through some functional limitations of static web pages and realize dynamic web page technology;

(2)ASP files are contained in files composed of HTML codes, which are easy to modify and test;

(3) The ASP interpreter on the server will make ASP programs on the server and send the results to the client browser in HTML format, so that all browsers can browse the pages generated by ASP normally;

(4)ASP provides some built-in objects, which can make server-side scripts more powerful. For example, you can get the information submitted by users through HTML forms from the web browser, process the information in the script, and then send the information to the web browser;

(5)ASP can use server-side ActiveX components to perform various tasks, such as accessing databases, discovering e-mails or accessing file systems.

(6) Because the server sends the result of ASP program execution back to the client browser in HTML format, users will not see the original program code written by ASP, and the stored ASP program code will be stolen.

The working principle of ASP

When ASP functions are integrated into a website, the following happens:

1. The user enters the URL in the browser address bar, and the default page extension is. asp。

2. The browser sends a request to the server.

3. The server engine starts to run ASP program.

4.ASP files are processed from top to bottom, script commands are executed, and HTML page contents are executed.

5. Send the page information to the browser.

The running environment of ASP

Asp needs to run under PWS or IIS. PWS or IIS service is attached to the CD of windows98 or windows2000, and can be installed through Add/Remove windows Components in Add/Remove Programs.

Generally, asp should be combined with access database or SQL Server database to compile powerful programs.

Web server software capable of running ASP

Windows2000 installs IIS 5.0 by default, windows xp installs IIS5. 1 by default, and windows 2003 installs IIS6.0 by default.

PWS (Personal web Server) is a simple personal web server running in windows98 environment.

The meaning and characteristics of ASP

ASP (Application Service Provider) refers to "an operator who provides application software services by lease through the network", that is, the operator takes application software as the main body and delivers services one-to-many through the network. This service-oriented trading model enables enterprises to have more cost-effective software use rights through leasing, and can also greatly reduce the maintenance cost of enterprises because of the centralized management of operators.

Basically, ASP has three characteristics: software service, service networking, the combination of information outsourcing service and network, product channelization and channel productization, which can even be regarded as the combination of ISP (Internet Service Provider) and ITS (Information Technology Service).

The English for ASP is Application Service Provider, and the Chinese standard translation is "Application Service Provider", which refers to a company or enterprise that provides management application solutions for commercial or individual customers. Recently, ASP has been heated by the media. IT is difficult for people who are not in IT industry to understand the content of ASP in the face of a bunch of technical terms. This paper tries to unveil the mystery of ASP with simple language for readers, and has some basic understanding of the popular ASP field in IT industry.

What is 1? ASP?

Simply put, ASP is a service provider that provides services to customers. There is no essential difference between accounting firms and marriage agencies. The difference is that ASP mainly uses the Internet as its main work and business tool, and provides standardized application software, related technical consultation and management leasing services to enterprises and companies in a one-to-many way. The concept of ASP was first put forward by Americans in 1998. At present, IT is regarded as the third network business model that can promote the development of network economy and has a solid foundation by major IT vendors around the world.

Compared with the traditional outsourcing service, the main difference of ASP is that ASP is a one-to-many business model, and the services it provides are compatible and coordinated. The charging method of ASP is generally monthly.

The insiders believe that ASP generally has such "members": telecom operators, traditional IT service providers, Internet access service providers (ISPs), independent software providers (ISVs), system integrators and pure ASP companies.

According to the popular view, ASP has the following five core connotations:

A.ASP focuses on applications and provides access to and management of applications.

B.ASP service can provide users with services that can be accessed in a "customized" brand-new application system environment, without the upfront investment of resources such as servers, personnel, systems and system authorization, such as ISP, and such services generally charge ASP service fees on a monthly basis.

C.ASP adopts centralized management-ASP generally has a management center, and all customers can access it remotely through the Internet to obtain technical support and consulting services.

D. One-to-many services, that is to say, ASP provides standardized product packages, and the products have been customized to the minimum or have not been customized by customers, which has reached practical and convenient standards for industry users.

E. delivery according to the contract. In the eyes of ASP customers, ASP is an organization that provides related services according to the contents of the customer agreement, and ensures that the services of the application service system can be truly fulfilled.

Why is 2.ASP popular?

From a big perspective, the core problem that puzzles the survival and development of domestic enterprises is management. With the popularization and application of Internet, enterprise users can directly rent ASP servers and software systems to manage their own business anytime and anywhere. The advantages of doing this are: First, enterprises can save a lot of IT construction costs and greatly reduce the cost of enterprise management informatization. Secondly, users of ASP can obtain applications and services in many ways, and software service products can form a perfect, efficient and advanced enterprise management system in a very short time through the network, and quickly obtain the integrated operation management scheme of enterprises.

The rapid development of network economy and e-commerce are also the main reasons. From portal to content, from attention to verticality, networks and websites gradually turn to ASP.

According to the author's understanding, the netizen "Bird" was the first person in China to get an electric shock from ASP. 1June, 1998, he spontaneously organized "Bird House" to study, exchange and discuss ASP technology, and now it has developed into the earliest ASP application technology service provider website in chinaasp.com and China. Shanghai Reciprocal Network Co., Ltd. combined with the actual situation in China, launched the ASP platform Reciprocal Network to serve domestic enterprises, providing enterprises with remote architecture and hosting services of internal and external network facilities and applications with e-commerce as the core, creating a virtual enterprise portal (EP), and directly applying ASP to commercial proliferation.

In addition, ISP has also turned to the embrace of ASP in an all-round way, which has become the product of ISP's further development. Software vendors have a soft spot for ASP. The latest news in the industry is that China Netcom, the third largest telecom company in China, has formulated the development strategy of ASP. Hamp, the largest management consulting company in China, has positioned its eight subsidiaries in the field of enterprise internal resource planning management (ERP), Beijing Liancheng Interactive will be positioned in the field of customer relationship management (CRM), and Beijing Digital Ark will be positioned in the field of network office. HP is discussing with China Construction Bank.

ASP is rising in the tide of IT economy, and its development prospect is immeasurable.

The Development Stages and Problems of 3.ASP

Various IT roles, mainly network service providers, software vendors and ISP, are making various attempts in the ASP field according to their own advantages. At present, the services provided by ASP are various, and there is no concept of standardization and quantification. Hardware vendors are moving closer to the "soil" and power direction of ASP, while software vendors and ISP are directly involved in the front line of ASP business.

The author estimates that after a period of trial and development, ASP will develop towards service integration, the initial standardization of products and services will be established soon, and then it will enter a period of market refinement, standard formulation and maturity of ASP products, and the steady growth of ASP will eventually become the core of the business model of IT industry!

At present, on the road of ASP development, the main problems are the change of ideas: replacing purchase with leasing, replacing product distributor with service integration, replacing product economy with service economy and so on. In fact, safety and service quality are the most important things for ASP and customers. ASP has a long way to go to realize the slogan of "leasing high technology" put forward by ASP!

ASP commonly used built-in functions

1, date/time function

These functions include displaying year, month, day, hour, minute, second, week and so on.

(1)Now function: Returns the current date and time value according to the date and time set by the computer system. Use method () immediately;

(2) Date function: only the date value set by the current computer system is returned. Usage: date ();

(3) Time function: only the time value set by the current computer system is returned. Usage: time ();

(4)Year function: returns an integer representing the year. Usage: year(date), where the date parameter is any parameter that can represent a date. For example, "year(date ())" means an integer that extracts the year from the date obtained by "date ()".

In addition, it can also be applied as follows: "year (# 520,2006 #)" means to extract the integer value of "year" in "May 20,2006". May 20, 2006 can also be expressed in the form of May 20, 2006 and May 20, 2006, that is, the combination of "a month and a day" and "a month and a day". Also note that "#" is used for inclusion to indicate the date value.

(5)Month function: returns an integer value between 1 and 12, representing a month in a year. Usage: month (date). The description of the parameter date is the same as that of the year function. But pay attention to the correctness of the date, such as "# 13-3 1-2006#", there is no "13" month at all, which is definitely wrong.

(6)Day function: returns an integer value between 1 and 3 1, representing a day in a month. Usage: Day (date). The description of the parameter date is the same as that of the year function. Also pay attention to the correctness of the date. For example, the 30th day defined for February in "#2-30-2006#" is wrong.

(7)Hour function: returns an integer value between 0 and 23, representing an hour in a day. Usage: hours (time). Where the parameter time is an arbitrary expression that can represent time. For example, "hour(time ())" is an integer that extracts "hour" from the time obtained from "time ()". Similarly, the parameter time can also use "hour (# 1 1:45:50#)" to indicate that the current hour is extracted from "45" minutes and "50" seconds of "1 1". Of course, the defined time should conform to the norms of time.

(8)Minute function: returns an integer value between 0 and 59, representing one minute in an hour. Usage: minutes (time). The description of the time parameter is the same as that of the hour function.

(9)Second function: returns an integer value between 0 and 59, representing one second in a minute. Usage: seconds (time). The description of the time parameter is the same as that of the hour function.

(10)Weekday function: Returns the integer of the day of the week. Usage: working day (date). The description of the parameter date is the same as that of the year function. The return values of this function are "1" to "7", representing "Sunday", "Monday" ... and "Saturday" respectively. For example, when the return value is "4", it means "Wednesday".

(1 1)WeekDayName function: Returns a string of a day of the week. Compared with the weekday function, it translates "what day of the week" and uses the method: weekdayname(weekday). The parameter weekday is the value of a specific day of the week. For example, "weekdayname(weekday(date ())" indicates what day it is today. Because "date ()" means the current time, "weekday(date ())" means an integer of a specific day of the week.

Of course, the string content finally displayed by the weekdayname function is also related to the current operating system language family. For example, the Chinese operating system will display Chinese characters such as "Monday", while the English operating system will display "mon" (Monday).

In addition, there are some calculation functions about time interval in VBScript:

(1)DateAdd function: Returns the date and time of the specified time interval. You can calculate how many years apart, or months apart, or hours apart, and so on. Usage: dateadd (interval, number, date).

Where the parameter interval indicates the time interval unit to be added. It is expressed as a string, such as "yyyy" for year, "q" for quarter, "m" for month, "d" for day, "ww" for week, "h" for hour, "n" for minute and "s" for second.

And the parameter number indicates the number of increased time intervals. It is expressed as a number and can be a negative number. Parameter date should be in the correct date and time format.

For example, dateadd ("D ",100," May 20, 2006 ") represents the date value of 100 days after May 20, 2006: August 28, 2006. Another example is dateadd ("h ",-12," 2005-5-20 10: 00 "), which indicates the date and time before 10 on May 20, 2005.

(2)DateDiff function: Returns the interval between two dates and times. You can calculate the age, hour and so on between two dates. Usage: datediff (interval, date 1, date2).

The description of the interval parameter in the parameter interval and dateadd function is the same, and the date 1 and date2 parameters are two dates and times that are compared with each other. In addition, when the date-time value of date 1 is greater than date2, it will be displayed as a negative value.

For example, datediff ("yyyy ","1982-7- 18 ",date) indicates how many years have passed since someone was born. Another example is datediff ("d ","1982-7- 18 ","2062-7- 18 "), which calculates how many days have passed in 80 years: 29220.

2. String processing function

In the function processing of scripts, it is usually necessary to decorate some strings. For example, filtering out sensitive words in strings to meet the requirements of final display; Another example is when a long string needs to extract the first few characters.

(1)Asc function: Returns the ANSI character code corresponding to the first letter in the string. Usage: asc (string). Where the string parameter represents a string.

(2)Chr function: returns the character corresponding to the specified ANSI character code. Usage: chr(chrcode). Parameter chrcode is the relevant identification number. This function corresponds to asc function.

For example: ASC ("A") stands for the ANSI character "97" of lowercase letter "A"; Similarly, chr(97) stands for "lowercase letter A". In addition, when the value of the parameter chrcode in chr(chrcode) is a number between 0 and 3 1, it indicates an unprintable ASCII code. For example, "chr( 10)" stands for line feed and "chr( 13)" stands for carriage return, which is often used to convert input and display formats.

(3)Len function: Returns the number of characters (bytes) in the string. Usage: len (string). For example, the value of len ("love") is 4.

(4)LCase function: Returns lowercase forms of all strings. Usage: lcase (string). For example, lcase ("cn Bruce") returns "cnbruce".

(5)UCase function: Returns the uppercase form of all strings. Corresponding lcase function. Similarly, ucase ("cn Bruce") is returned as "cnbruce".

(6)Trim function, LTrim function and RTrim function: return string contents without spaces before and after respectively. For example:

Trim(" cnbruce ") is returned as" cnbruce "with no spaces before and after;

Ltrim(" cnbruce ") is returned as" cnbruce "without leading spaces;

Rtrim(" cnbruce ") is returned as" cnbruce "without spaces;

This function is often used in registration information, such as ensuring spaces before and after the registered user name.

(7)Left function: returns a specified number of characters from the left side of the string. Usage: left (string, length). For example, left ("brousce ",5) is returned as" Brous ",that is, the first five characters.

(8)Right function: returns a specified number of characters from the left side of the string. Usage: right (string, length). For example, right ("Brousce ",4) is returned as" usce ",that is, the last four characters.

(9)instr function: Returns the position where a string first appears in another string. For example, to find the first occurrence of the letter "a" in the string "a11c11861",you can use instr (my _ string, "a"

(10)Mid function: Returns a specified number of characters from a string. For example, the current "1 10" should get three units from the second bit of the string "a110/1".

(1 1)Replace function: find and replace the specified string in the string. Replace (strtobeseached, strychforiswith) where strtobeseached is a string, strychfor is a substring to be searched, and strreplacewith is a substring to be replaced. For example, replace (rscon, "

3. Type conversion function

Cbool(string) is converted to a Boolean value.

Cbyte(string) is converted to a value of type byte.

Ccur (string) is converted to a monetary value.

Cdate (string) was converted to a value of type days ago.

Cdbl (string) is converted to a double-precision value.

Cint (string) is converted to an integer value.

Clng (string) is converted to a long integer value.

Csng (string) is converted to a single-precision value.

Cstr(var) is converted into a string value.

A string(var) value is converted to a string.

The Val(string) string is converted into a numerical value.

4. Operating function

Abs(nmb) returns the absolute value of the molecule.

Atn(nmb) returns the arc tangent of a number.

Cos(nmb) returns the residual value of an angle.

Exp(nmb) returns the power of the natural index.

Int(nmb) returns the integer (carry) part of a number.

Fix(nmb) returns the shaping (rounding) part of a number.

Formatpercent (expression) returns a percentage.

Hex(nmb) returns the data of 16 hexadecimal number.

Log(nmb) returns the natural logarithm.

Oct(nmb) returns the octal number of a number.

Rnd returns a random number greater than "0" and less than "1", but it needs to be declared by randomize to generate a random seed.

Sgn(nmb) judges the sign of numbers.

Sin(nmb) returns the positive value of the angle.

Sqr(nmb) returns the square root of a number.

Tan(nmb) returns the tangent of a number.

5. Other functions

IsArray(var) determines whether the variable is an array.

IsDate(var) determines whether the variable is a date.

IsNull(var) determines whether the variable is empty.

IsNumeric(var) determines whether the expression contains numeric values.

IsObject(var) determines whether a variable is an object.

TypeName(var) returns the data type of a variable

Array(list) returns an array.

Split(liststr) returns a one-dimensional array from a list string.

LBound(arrayP) returns the minimum index of an array.

Ubound(array) returns the maximum index of an array.

Create an object.

Gets the file object.

Applications and session objects in ASP

I. Overview of application object members

Application object members include collections, methods and events of application objects.

1. A batch of 1. ⒈Application items.

Contents collection: A collection of all variables stored in the Applicaiton object that are not defined by elements.

StaticObjects: A collection of all variables stored in the application objects defined by elements.

For example, there are the following assignments in default.asp.

Application ("a")="a"

Application ("b")= 128

Application ("c ")= false

There is a content collection.

Apply. Contents (1) = "a "'can also be written as application.contents("a")="a"

Apply. Contents (2) = 128' can also be written as application. Content ("b") = 128.

Application.contents(3)=false' can also be written as Application. Contents ("c") = false。

Here, I recommend that you use methods such class application.contents("a ") when calling, because it is more intuitive. If it is expressed by serial number, the order of assignment should be considered.

4. The method of the 4.⒉Application object.

Content. Remove ("variable name "): Removes the specified variable from the application. Content collection.

Content. RemoveAll (): Delete all variables in the application. Content collection.

Lock (): Lock the application object so that only the current ASP page can access the content.

Unlock (): Unlock the application object.

Example: In default.asp:

Application ("a")="a"

Application ("b")= 128

Application ("c ")= false

response . write application . contents( 1)amp; "

"

Response. Write applications. Content (2)&; "

"

Response. Write applications. Content (3)&; "

"

After deleting b

application.contents.remove("b ")

response . write application . contents( 1)amp; "

"

Response. Write applications. Content (2)&; "

"

Implementation results:

a

128

wrong

After removing b:

a

wrong

If you want to delete all the variables in the collection, you can use application.contents.removeall. As for the Lock and Unlock methods, they are often used in practice and readers are familiar with them, so I won't repeat them here.

[13] 13. Application against the event

OnStart: Occurs when the first user who accesses the server accesses the page for the first time.

OnEnd: Occurs when the last user's session has ended and all the codes of the OnEnd event of this session have been executed, or after the last user has visited the server for a period of time (generally 20 minutes), no one has visited the server.

To define what to do in the OnStart and OnEnd events of the application object, you need to write code in the file Global.asa (an example is given below) and put the file in the root directory of the site (generally Inetpub\wwwroot\).

Second, an overview of session object members.

The members of the Session object have one more property than the Application object, namely, collection, property, method and event.

A batch of 1. ⒈Session items.

Content: A collection of all variables stored in a specific session object, which are not defined by elements.

StaticObject: a collection of all variables defined by the element and stored in the Session object.

For example, there are the following assignments in default.asp.

Session ("a")="a"

Session ("b")= 128

session("c")=false

There is a content collection.

Session.contents( 1)="a "'can also be written as session.contents("a")="a"

Session.contents(2)= 128' can also be written as session. Content ("b") = 128.

Session.contents(3)=false' can also be written as session.contents("c")=false.

4. The properties of the 4.⒉Session object.

Code page: readable/writable. Integer defines a code page for displaying page content in a browser. A code page is a numeric value of a character set, and different languages use different code pages. For example, ANSI code page is 1252, Japanese code page is 932, and Simplified Chinese code page is 936.

LCID: readable/writable. Integer defines the page area ID sent to the browser. LCID is an international standard abbreviation that uniquely identifies a region. For example, in 2057, the currency symbol defining the current region was "£".

SessionID: read only. Long integer. Returns the session identifier of this session. Every time a session is created, the server automatically assigns an identifier. According to its value, it can be judged which of the two users accesses the server first.

Timeout: readable/writable. Integer defines the timeout limit (minutes) for the session. If the user does not refresh or request any web pages within this time, the user-generated session will automatically end. The default value is 20.

The above attributes have little effect in practical application, and basically do not need to be modified, and there is nothing special about these attributes.

3. The method of the 3.⒊Session object.

Content. Remove ("variable name "): Removes the specified variable from the Session.contents collection.

Content. Removeall (): Deletes all variables in the Session.contents collection.

About (): ends the current user session and cancels the current session object.

What's in it Delete ("variable name") and content. The Removeall () method of the Session object is basically the same as that of the Application object. To help you understand, you can refer to the example above to change the application to a session. What I want to explain here is the difference in content. Removeall () and discard (). Both methods will release current.

All session variables of a user session are different in content. Removeall () only releases the value of the Session variable without terminating the current session, while value () not only releases the session variable, but also terminates the session and triggers the Session_OnEnd event. I hope everyone will pay attention to the difference between the two.

4. The event of the 4.⒋Session object.

OnStart: Triggered when an ASP user session is generated. This event is generated whenever any user requests any page from the server.

OnEnd: Triggered when the ASP user session ends, and also triggered when using the above () method or timeout.

These two events, like the OnStart and OnEnd events of the application, must also be placed in the Global.asa file.

I will focus on the use of these four events with you.

Three. Global. asa

The application and session objects of ASP embody the features that other ASP built-in objects don't have-events. Each visitor triggers an OnStart event when accessing the server (the first visitor triggers the OnStart event of both the application and the session, but the application precedes the session), and each visitor triggers an OnEnd event when the session ends (the last visitor triggers the OnEnd event of both the application and the session, but the session precedes the application).

OnStart and OnEnd are generally used to count the number of online users and modify the online and offline status of users in virtual communities. To clearly define these two events, you need to write code in the Global.asa file and put the file in the root directory of your site (default is \Inetpub\wwwroot\). In addition, Application and session objects specify that no other ASP built-in objects (response, request, server, session ...) can be used in OnEnd events, except the application object. Here is an example of a virtual community that counts online people to illustrate how to use these two events.

Document description:

Global.asa is located in d:\Inetpub\wwwroot\ directory.

Default.asp is located in the d:\Inetpub\wwwroot\ directory, and the virtual community login page.

Login.asp is located in the directory d:\Inetpub\wwwroot\ and is used to detect the user name and password entered by the user.

Index.asp is located in the directory d:\Inetpub\wwwroot\ on the homepage of the virtual community.

Bbs.mdb is located in the directory d:\Inetpub\wwwroot\ and is a database for storing user information.

Database (access) structure:

===bbs table = = =

ID user id, long integer

Name user name, text type

Code password, text type

Online online status, Yes/No.

===global.asa===

< script LANGUAGE = " VBScript " RUNAT = " Server " >

Sub-application _OnStart

Application ("Online") =0

End joint

Sub-application _OnEnd

Nd connector

Subsession _OnStart

End joint

Sub-session _OnEnd

If session.contents("pass "), then' judge whether it is the Session_OnEnd of the logged-in user.

Applications. Locks

Application ("Online") = Application ("Online")-1

Application. Unlocking

If ... it will be over.

End joint

===login.asp===

..... password verification, connect to the database, and check whether the user name and password entered by the user are correct.

If the password is verified, then

Session ("name") =rs ("name")

Session ("id")=rs("id")

session("pass")=true

other

Rs off

Connection closed

Response. Write "Wrong password!"

Response. End

If ... it will be over.

Applications. Locks

Application ("Online") = Application ("Online")+1

conn . Execute(" update BBS set online = 1 where id = " & amp; Session ("id"))'