200 likes | 353 Views
A S P. Presented by: Yu, zhu Time :2003.10.20. Outline . The introduction of ASP Why we choose ASP How ASP works Basic syntax rule of ASP ASP’S object model An example of ASP (management system of chat room) Limitations of ASP Summary. Introduction. What is the ASP
E N D
A S P Presented by: Yu, zhu Time :2003.10.20
Outline • The introduction of ASP • Why we choose ASP • How ASP works • Basic syntax rule of ASP • ASP’S object model • An example of ASP (management system of chat room) • Limitations of ASP • Summary
Introduction What is the ASP ASP (Active Server Pages) is a technology developed by Microsoft. Pages using ASP are primarily developed in JavaScript, VBScript , or PerlScript and are integrated into the HTML of your Web pages. The ASP code is compiled by the server and the resulting output is standard HTML. By using ASP, Web pages can be dynamic, full of ever-changing content, and browser independent
Introduction (Cont.) Here's the official word from the Microsoft site: "Active Server Pages is an open, compile-free application environment in which you can combine HTML, scripts, and ActiveX server components to create dynamic and powerful Web-based business solutions. Active Server Pages enables server-side scripting for IIS with native support for both VBScript and Jscript." and the highest version of IIS is IIS 5.0
Why we choose ASP What can we do by using ASP • Server-side ASP scripts can be used to store HTML form information in a database, personalize Web sites according to visitor preferences, or use different HTML features based on the browser. • separate the design of your Web page from the details of programming access to databases and applications , allowing programmers and Web designers to focus on what they do best. • Can call other programs to do things like access databases, serve different pages to different browsers
Why we choose ASP (Cont.) The benefits of ASP • ASP runs as a service of the Web server, and is optimized for multiple threads and multiple users. • you can create ASP pages using whatever language you want. • ASPs can also take advantage of COM and DCOM objects with minimum effort. • Server-side scripts cannot be readily copied because only the result of the script is returned to the browser; users cannot view the script commands that created the page they are viewing.
How ASP works (Cont.) Have a look at the diagrams below. They are pretty simplistic and self-explanatory.
The Basic syntax rule of ASP ASP contain the server scripts, which can contain any expressions, statements, procedures, operators valid for the scripting language. These server scripts are enclosed by the delimiters <% and %> • 1. VBScript • 2. JavaScript • 3. Other Scripting Languages
ASP’S object model • 1. Request Object • 2. Response Object • 3. Server Object • 4. Session Object • 5. Application Objects
An example of ASP • A management system of a small chat room In this management system of the chat room, files are used to record the data. This management system is used to kick out some users.
An example of ASP (source code) <%Response.Expires=0 manage=Session("hqtchatmanage") if manage<>"Administrator" then Response.Write “visit declined" : Response.end username=Request.QueryString("username") dim online() onfile=server.mappath("online.asp") get the path of the online.asp Set fs=CreateObject("Scripting.FileSystemObject") establish the “Filesystemobject” objection,and set the fs as the variable Set thisfile = fs.OpenTextFile(onfile,1,False) counton = 0 do while not thisfile.AtEndOfStream thisline = thisfile.readline Get a line of data from the file Redim preserve online(counton) define an array online(counton) = thisline counton = counton + 1 loop
An example of ASP (source code) thisfile.Close Set outfile = fs.CreateTextFile(onfile) for i=0 to counton-1 step 3 if online(i)<>username then If the user are not deleted outfile.WriteLine online(i)output all of the data of this user, and rewrite the outfile.WriteLine online(i+1)data to the online.asp. And replace the original outfile.WriteLine online(i+2)data ofonline.asp. So you can just see the users end if except the name of this user who was kicked out! next outfile.Close Close this file set fs=nothing Response.Redirect "onlinelist.asp" %>
An example of ASP (Cont.) • This function is achieved all by files instead of the database. At first, establish a temporary file folder (outfile). Output the data of the users’ information such as username, IP address and so on and store in this folder. Then write into the file (online.asp) that recorded the users’ information orderly and replace the original data in this file.
Limitations of ASP • Many of the functions of ASP will perform often in a data driven website take several lines of repetitive code each time to perform. • Sometimes, the code of ASP will become repetitive and is somewhat time consuming. • ASP is the lack of a good development environment. ASP is extremely robust, working well with the Windows platform on many levels, but is often convoluted and finding good support documentation and code examples can be excruciating. • And if you are not proficient in Visual Basic or programming, ASP is a very difficult language to learn.
Summary • ASP was designed as a faster and easier alternative to CGI scripting using Perl or C. It provides an easy-to-learn scripting interface (including native support for VBScript and JScript), along with a number of predefined objects that simplify many development tasks, such as maintaining user state and defining global variables within an application. ADO components can be used to perform additional functions, including accessing ODBC-compliant databases, and outputting data to text files. Java components and XML can be used to extend ASP scripts
Reference • http://www.asp101.com/ • http://www.aspin.com/ • http://www.powerasp.com/ • http://hotwired.lycos.com/webmonkey/98/39/index2a.html • http://www.asp-help.com/ • http://www.webopedia.com/TERM/A/Active_Server_Pages.html • http://www.aspronline.com/ • http://www.oreilly.com/catalog/designasp/ • http://www.codefixer.com/tutorials/how_asp_works.asp