Link:http://output.to/sideway/default.asp?qno=120200040 Contents.Remove / Contents.RemoveAll Application ObjectOne of the key functions of Application Object is the application data control on the server. Application.Contents.Remove MethodApplication.Contents.Remove Method removes or deletes an item from the Contents collection of Application object.. Syntax:
Contents.Remove( Or in an ASP file. Imply <% Application.Contents.Remove(id) %> Parameters:id The parameter "id" , a string or an integer, is used to specify the name of the item to be removed. If id is a string, the specified name of the item in the contents collection will be removed. If id is an integer, the corresponding indexed item in the contents collection will be removed. Return Values:void This method has no return values. Remarks:The id can be either a string of an integer. If id is a string, the specified name of the item in the contents collection will be removed. If id is an integer, the corresponding indexed item in the contents collection will be removed. However, the index of the collection will be updated after the removal of an item from the collection. Therefore, better to identify an item by its name. The ASP collection support only the Count property and the Item, Remove, and RemoveAll methods. The Add method is not support and the item is added by declaration. Examples:
Application.Contents.RemoveAll MethodApplication.Contents.RemoveAll Method removes or deletes all item from the Contents collection of Application object.. Syntax:
Contents.RemoveAll( Or in an ASP file. Imply <% Application.Contents.RemoveAll %> Parameters:void This method has no parameters. Return Values:void This method has no return values. Remarks:All items in the Application.Contents collection are removed. Examples:
Link:http://output.to/sideway/default.asp?qno=120200043 Abandon / Timeout / SessionID Session ObjectOne of the key functions of Session Object is the session control on the server. Session.Abandon MethodSession.Abandon method abandons or destroys a Session object and all related resources are released after finised processing the current page. Syntax:
Abandon( Or in an ASP file. Imply <% Session.Abandon %> Parameters:void This method has no parameters. Return Values:void This method has no return values. Remarks:By default, the server destroys all session objects when the session is finished or times out. The Session.Abandon method allows the abandon of the current session of a client by destroying all session object after finished processing the current page. And create a new session object for the subsequent request by same client. All variables and objects will then be stored in this new session object. In other word, there is always a sesson object for each client. The session.Abandon method only set the flag for the deletion of all current session objects after the completion of all script commands on the current page. Therefore the Abandon method can be placed anywhere before the end of script commands in the same page. And therefore variables stored in the Session object are still available on the same page, but not in any subsequent web pages by the same client. Examples:
Session.Timeout PropertySession.Timeout property sets the length of time out period for the Session object of the application that allowing the client to refresh or request a page on the server before the end of session on the server. Syntax:Session.Timeout [=nMinutes] Or in an ASP file. Imply <% Session.Timeout [=nMinutes] %> Parameters:nMinutes The parameter "nMinutes" is used to specify the allowed idle time, in minutes, of a session before the server terminates the session automatically. The default value is 10 minutes. Remarks:The Session.Timeout is related to the idle time of the client when the user does not refresh or request a page. There is no hard-coded limit on the value of Session.Timeout. The value can be set to 8 minutes or less. It should not be set too low, i.e. lower than 4 minutes because clients rarely respond within that time resulting in a loss of session state. It should also not be set too high, i.e. higher than 20 minutes escept in some special cases because every open session is holding onto memory. But in IIS 6.0, the minimum allowed value is 1 minute and the maximum is 1440 minuites. Examples:
Session.SessionID PropertySession.SessionID property returns the unique of LONG data type session identifier generated by the server during the creation of the new session.. Syntax:Session.SessionID Or in an ASP file. Imply <% Session.SessionID %> Parameters:void This method has no parameters. Remarks:Although the SessionID is a unique number on the running Web server. Some of the SessionID value may be the same as those SessionID generated before the web server stopped. Therefore SessionID property can not be used to generate the primary key values for an application. Examples:
Link:http://output.to/sideway/default.asp?qno=120200044 CodePage Session ObjectAnother important function of Session object is the control of ASP engine for the HTML output. Session.CodePage PropertyResponse.CodePage property Add or set the CodePage for data in the intrinsic objects within the entire session. Syntax:Session.CodePage(=CodePageID) Or in an ASP file. Imply <% Response.CodePage(=CodePageID) %> Parameters:CodePageID The parameter "CodePageID" is the page code to represent the character code formatting used for the HTML output. The data type of "CodePageID" is integer. The possible CodePageID are
Remarks:The Session.CodePage property is used to specify CodePage of the body content of pages in a session. Each output body content should have only one character set, otherwire the displayed characters will be incorrect. For each character set, there is a corresponding code page to represent the character code encoded in the intrinsic objects. And therefore there is always a code page for every response body output. If Response.CodePage is not explicitly set in a page, the value of CodePage for the page should be determined from other settings. If sessions are enabled, the Response.CodePage can then be implicitly set by the Session.CodePage. If sessions are not enabled and the @CodePage is present in the ASP file, the Response.CodePage can then be set by the @CodePage. If the @CodePage is not present in the ASP file, the Response.CodePage can then be set by the ASPCodePage metabase property. If the ASPCodePage metabase property is also not set or is set to 0, the Response.CodePage is then set by the system ANSI code page. In IIS 5.0 later, Session.CodePage is no longer implicitly set by @CodePage as before. The change was made because @CodePage and Response.CodePage affect only single responses, and Session.CodePage affects all responses in a session. while @CodePage could change the code page for an entire session in IIS 5.0 and eariler version. In the case, the code page is set explicitly in two pages or in two different response outputs with one response output is called by the other response output, through #include, Server.Execute, or Server.Transfer, usually the code page of the child response output will be set by the parent response output. However if a Response.CodePage is explicitly set in the parent page of a Server.Execute call, an @CodePage command in the child page will override the parent code page. So, the explicit setting of Response.CodePage or Session.CodePage for nonliteral strings should be set before senting the output to the client. Besides the encoding of the response output of nonliteral strings in the intrinsic objects, the encoding of the literal strings in a script are still set by the @CodePage if present, the AspCodePage metabase property value if set, or the system ANSI code page with the same priority as for intrinsic objects. Therefore, when both literal and nonliteral strings are used in the same page, the code page setting by @CodePage should match with the code page setting by Response.CodePage, or the page will display incorrectly because the literal strings are encoded differently from the nonliteral strings in the response output. Since the system default code page will be used when there is no code page setting in a web page, sometimes it is not necessary to set a code page in the web page for those web client with matched system default code page. However, setting the code page for a web page is alway necessary for encoding the response output correctly for all web client in the WWW.n the WWW. And therefore if the code page is set in a page, the Response.Charset should also be set in order to ensure the response output is displayed correctly for all web client in the WWW. In order to make the response output display correctly, the file format of a web page must be stored with the same @CodePage setting used in the page. In window, notepad can save files in UTF-8 format or in the system ANSI format. Therefore the ASP file should be saved in UTF-8 format if the @CodePage is set to 65001. Since notepad can save files in system ANSI format according to the default system locale setting in the Regional and Language Options in the Control Panel, notepad can save file in different file format according to @CodePage setting by changing the system locale setting before saving the file. Similarly, in order to test web pages that use different code pages and character sets in a client computer, the corresponding language packs should also be installed through the adding of language packs in the Regional and Language Options in the Control Panel. Examples:
|
Sideway BICK Blog 12/02 |