ServerSide Web Programming with Active Server Pages ASP
Server-Side Web Programming with Active Server Pages ASP Server Object 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 1
ASP Intrinsic Objects • • • Request - Exposes what client sent to server. Response - Collects output back to client. Application - Represents the ASP page itself. Session - represents a continuity of connection. Server - provides services to the application. Object. Context - For MTX and transactions. 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 2
ASP Server Object • Grab bag of various functions, some of which are used in nearly ASP page. – Script. Timeout property – Create. Object method – HTMLEncode method – Map. Path method – URLEncode method 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 3
Server. Script. Timeout Property • By default, ASP will process a page request up to the default of 90 seconds. • You probably should decrease the defalt timeout by setting the ASPScript. Timeout in IIS metabase. • Server. Script. Timeout can not set a timeout less than the IIS metabase default. • Pages requiring long timeouts are too expensive… Server. Script. Timeout = xx seconds 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 4
Server. Create. Object Method • Key feature of ASP it to instantiate components to extend and/or optimize server-side functionality. • IIS uses Microsoft Transaction Server (MTS) to share instantiated components across multiple pages. • Many sources of components: – IIS add-ons – Third Party components (ensure they are ASP-ready) – Custom-built in VB, C++, etc. 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 5
Server. Create. Object Method Dim obj. Conn ‘ADO Connection object Set obj. Conn = Server. Create. Object("ADODB. Connection") obj. Conn. Open "connection string" … obj. Conn. Close Set obj. Conn = Nothing 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 6
Server. Create. Object Guidelines • Objects take server resources (memory, connections, etc. ). Use them sparingly. • Instantiate objects at beginning of page, unless page is very long. • Always use an object’s method for “closing” itself and then set the object to “nothing”. • In general, an object's resources are not released until ASP has finished processing the page even if you have released the object. 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 7
Server. Map. Path Method • Returns the physical path of a file on a server • Typically used with File. System. Object • Can return relative or virtual paths -- omitting the leading ‘/’ will return a relative path from the ASP page being executed. 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 8
Server. Map. Path Examples • Assume script is running in an ASP page where the actual physical path for the webserver’s root directory is d: inetpubwwwroot response. write server. mappath("/test. asp") returns d: Inetpubwwwroottest. asp response. write server. mappath(”. ") returns d: Inetpubwwwroot response. write server. mappath(”/ts/ts. asp") returns d: Inetpubwwwroottsts. asp 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 9
HTMLEncode Method • Used to send HTML and script code to the client without actually executing it. • Syntax: Server. HTMLEncode(“xx “) Response. Write Server. HTMLEncode("<table>") Returns: < table> instead of <table> • Often used with outputting previously entered user -input text. • To close ASP script blocks, precede the closing angle bracket with a backslash Response. Write Server. HTMLEncode("<%Server. Map. Path('. ')%>") 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 10
URLEncode Method • We will discuss this next week. . . 1/18/2022 © 2000, Valtara Digital Design/Blitzkrieg Software 11
- Slides: 11