Download presentation
Presentation is loading. Please wait.
Published byBarry Mills Modified over 9 years ago
1
Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5
2
Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : menghasilkan web page yang dinamis menggunakan ASP dengan bahasa VBScript (C3)
3
13.1 Introduction 13.2 How Active Server Pages Work 13.3 Client-side Scripting versus Server-side Scripting 13.4 Using Personal Web Server or Internet Information Server 13.5 Active Server Page Objects 13.6 A Simple ASP Example 13.7 Server-side ActiveX Components 13.8 File System Objects 13.9 Session Tracking and Cookies Outline Materi
4
13.1 Introduction Active Server Pages (ASP) –Processed in response to client request –ASP file contains HTML and scripting code –VBScript de facto language for ASP scripting Other languages can be used –JavaScript –.asp file extension –Microsoft-developed technology –Send dynamic Web content HTML DHTML ActiveX controls Client-side scripts Java applets
5
13.2 How Active Server Pages Work Client sends request –Server receives request and directs it to ASP –ASP processes, then returns result to client HTTP request types –Request methods GET –Gets (retrieves) information from server –Retrieve HTML document or image POST –Posts (sends) data to server –Send info from HTML form continue..
6
13.2 How Active Server Pages Work Browsers often cache Web pages –Cache: save on disk –Typically do not cache POST response Next POST request may not return same result Client requests ASP file –Parsed (top to bottom) by ActiveX component asp.dll –Parsed each time requested –Web server must support ASP by providing component such as asp.dll
7
13.3 Client-side Scripting versus Server-side Scripting Client-side scripting –Commonly used –Browser-dependent Scripting language must be supported by browser or scripting host –Viewable on client Protecting source code difficult –Reduces the number of requests the server receives –Enhance a Web page’s content Richer functionality than HTMl
8
13.3 Client-side Scripting versus Server-side Scripting Server-side scripting –Reside on server –Greater flexibility – database access –Usually generate custom response for client –Access to ActiveX server components Extend scripting language functionality –Run exclusively on server cross-platform issues not a concern –Not visible to client Only HTML + client-side scripts sent to client
9
13.4 Using Personal Web Server or Internet Information Server ASP requires –Web server Personal Web Server (PWS) 4.0 Internet Information Server (IIS) 4.0 –Database –. mdb files –Configuration for examples in this book can be found on page 778 May have to change paths in.asp files to reflect your directory structure
10
13.5 Active Server Page Objects ASP has several built-in objects –Request object Access information passed by GET or POST Used to access cookies –Response object Sends information such as HTML or text to client –Server object Provides access to server methods and properties Provides method CreateObject –Used to instantiate other objects
11
13.6 A Simple ASP Example Scripting delimiters – –Indicate code is to be executed on server, not client @LANGUAGE –Specify scripting language (default VBScript) – Each time page refreshed, server loads and interprets ASP Sample Program Sample Output File
12
13.7 Server-side ActiveX Components Server-side ActiveX components –Typically do not have GUI –If scripting language for ASP not support certain feature, create ActiveX Server component Visual C++, Visual Basic, Delphi, etc. –Usually execute faster than scripting language equivalents –Executed on server Client does not need to support ActiveX technologies continue.. Sample Program1 Sample File Output1 Sample Program2 Sample Config.txt File
13
13.7 Server-side ActiveX Components Some server-side ActiveX components included with IIS and PWS © Copyright 2001 by Deitel & Associates. All Rights Reserved
14
13.8 File System Objects File System Objects (FSOs) –Manipulate files, directories and drives –Read and write text –In Microsoft Scripting Runtime Library –5 FSO types: FileSystemObject –Interact with File s, Folder s and Drive s File –Manipulate File s of any type Folder –Manipulate Folder s (i.e, directories) continue..
15
13.8 File System Objects Drive –Gather info about Drive s (local or remote) TextStream –Read and write text files OpenTextFile(filename, code, create) –filename - file to open –code 8 - open for appending 1 - open for reading 2 - open for writing –create? - if true, creates a new file if does not exist continue.. Sample Program Sample Output File
16
13.8 File System Objects continue.. © Copyright 2001 by Deitel & Associates. All Rights Reserved
17
13.8 File System Objects continue.. © Copyright 2001 by Deitel & Associates. All Rights Reserved
18
13.8 File System Objects continue.. © Copyright 2001 by Deitel & Associates. All Rights Reserved
19
13.8 File System Objects © Copyright 2001 by Deitel & Associates. All Rights Reserved
20
13.9 Session Tracking and Cookies Customized services –http://my.yahoo.com/http://my.yahoo.com/ –Shopping cart –Marketing Track clients –Session tracking Handled by server ASP: Session object –Timeout property »Default: 20 minutes »Terminate with Abandon method continue.. Sample Program Sample Output File
21
13.9 Session Tracking and Cookies Cookies –Small files sent as part of response to client –Every HTTP interaction between client and server includes header Contains info about request or response –Request: type of request ( GET or POST ) and cookies stored on client machine –Maximum age Duration of browsing session Store cookies on client computer for future use Cookies automatically deleted when expire continue.. Sample Program Sample Output File
22
13.9 Session Tracking and Cookies ASP application –Multiple ASP pages linked through POST requests Server side include (SSI) –SSI statement replaced with contents of file –SSI statements always execute before any scripting code –.inc extension Virtual paths vs. physical paths Sample Program Sample Output File
23
End of Session 13
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.