Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Search Stardeveloper.com
Stardeveloper RSS Feed
Newsletter
Enter your email address below to be informed every time a new article is posted at Stardeveloper.com:

You can follow Faisal Khan on Twitter
Article Categories
.NET  .NET
  ASP (16)
  ASP.NET (41)
  ADO (16)
  ADO.NET (10)
  COM (6)
  Web Services (4)
  C# (1)
  VB.NET (3)
  IIS (2)

J2EE  J2EE
  JSP (15)
  Servlets (9)
  Web Services (1)
  EJB (4)
  JDBC (4)
  E-Commerce (1)
  J2ME (1)
  Products (1)
  Applets (1)
  Patterns (1)
Log In
UserName Or Email:

Password:

Auto-Login:

Miscellaneous Links
  Submit Article

Hosted by Securewebs.com
 
Home : .NET : ASP : Built in ASP objects - Active Server Pages Reference
 

The Server Object
The Server object makes us available the methods and properties of our server ( IIS ).

Syntax

Server.property|method
Properties Description
ScriptTimeout An integer which specifies time in seconds until which the script can run after that the server aborts the script and displays an error message.

Methods Description
CreateObject Creates an instance of the object ( a component, application or a scripting object ). The component can be instantiated by giving its CLSID or ProgID in the Server.CreateObject method e.g. Server.CreateObject ("MSWC.MyInfo").
Execute Executes the given .asp page and then returns the control to the page who called the method. Very useful method which can be used to execute another .asp page without leaving the current page and then control is passed back to the calling page.
GetLastError Returns an ASPError object which can be used to get information about the last error occured in the ASP script.
HTMLEncode Provides HTML encoding to a given string. All non-legal HTML characters are converted to their equivalent HTML entity e.g. "<" is converted to &lt; .
MapPath Maps the specified virtual or relative path into physical path of the server.
Transfer Transfers the control of the page to another page specified in the URL. Note that unlike Execute, control of the page is not returned to the page calling the Server.Transfer method.
URLEncode Provides URL encoding to a given string e.g. Server.URLEncode ("http://www.stardeveloper.com") returns http%3A%2F%2Fwww%2Estardeveloper%2Ecom.

The Session Object
The Session object is automatically created every time client browser access pages from your web site. Session object is specific for every user and varies from user to user. It can be used to store variables specific for a user and IIS will maintain these variables when the client moves across pages within your site. You can create and access Session scope variables. You can store user specific preferences within Session object such as 'font-size, background-color' etc.

Note that scripts for different Events are to be declared in global.asa file.

Syntax

Session.collection|property|method
Collections Description
Contents Contains all the items which have been added to the Session object. You can iterate through the Contents collection and retrieve a list of all the items added or you can retrieve a specific item. Note that it contains all the Session items except the ones created using <object> element.
StaticObjects Contains all the items which have Session scope created using <object> element. As with Session.Contents collection you can iterate through the StaticObjects collection to get a list of items or you can get a specific item out of the StaticObjects collection.

Properties Description
CodePage An integer which defines the code page to be used to display content to the client browser e.g. code page 1252 is used to for American english and most European languages and 932 is used for Japanese kanji.
LCID Stands for locale identifier. It is a standard international abbreviation that uniquely identifies the locale e.g. LCID 2057 stands for British locale.
SessionID A long which returns the session identifier for this client browser.
Timeout An integer which specifies a time out period in minutes. If the client doesn't refresh or request any page of your site within this time out period then the server ends the current session. If you do not specify any time out period then by default time out period is 20 minutes.

The Server Object
The Server object makes us available the methods and properties of our server ( IIS ).

Syntax

Server.property|method
Properties Description
ScriptTimeout An integer which specifies time in seconds until which the script can run after that the server aborts the script and displays an error message.

Methods Description
CreateObject Creates an instance of the object ( a component, application or a scripting object ). The component can be instantiated by giving its CLSID or ProgID in the Server.CreateObject method e.g. Server.CreateObject ("MSWC.MyInfo").
Execute Executes the given .asp page and then returns the control to the page who called the method. Very useful method which can be used to execute another .asp page without leaving the current page and then control is passed back to the calling page.
GetLastError Returns an ASPError object which can be used to get information about the last error occured in the ASP script.
HTMLEncode Provides HTML encoding to a given string. All non-legal HTML characters are converted to their equivalent HTML entity e.g. "<" is converted to &lt; .
MapPath Maps the specified virtual or relative path into physical path of the server.
Transfer Transfers the control of the page to another page specified in the URL. Note that unlike Execute, control of the page is not returned to the page calling the Server.Transfer method.
URLEncode Provides URL encoding to a given string e.g. Server.URLEncode ("http://www.stardeveloper.com") returns http%3A%2F%2Fwww%2Estardeveloper%2Ecom.

The Session Object
The Session object is automatically created every time client browser access pages from your web site. Session object is specific for every user and varies from user to user. It can be used to store variables specific for a user and IIS will maintain these variables when the client moves across pages within your site. You can create and access Session scope variables. You can store user specific preferences within Session object such as 'font-size, background-color' etc.

Note that scripts for different Events are to be declared in global.asa file.

Syntax

Session.collection|property|method
Collections Description
Contents Contains all the items which have been added to the Session object. You can iterate through the Contents collection and retrieve a list of all the items added or you can retrieve a specific item. Note that it contains all the Session items except the ones created using <object> element.
StaticObjects Contains all the items which have Session scope created using <object> element. As with Session.Contents collection you can iterate through the StaticObjects collection to get a list of items or you can get a specific item out of the StaticObjects collection.

Properties Description
CodePage An integer which defines the code page to be used to display content to the client browser e.g. code page 1252 is used to for American english and most European languages and 932 is used for Japanese kanji.
LCID Stands for locale identifier. It is a standard international abbreviation that uniquely identifies the locale e.g. LCID 2057 stands for British locale.
SessionID A long which returns the session identifier for this client browser.
Timeout An integer which specifies a time out period in minutes. If the client doesn't refresh or request any page of your site within this time out period then the server ends the current session. If you do not specify any time out period then by default time out period is 20 minutes.

Previous ( 3 Gone )( 1 Remaining ) Next

See all comments and questions (post-ad) posted for this tutorial.


Comments/Questions ( Threads: 8, Comments: 12 )
    Contains 1 or more replies by the Author of this Article.
    Contains 1 or more replies by Faisal Khan.

  1. Insert data in access
  2. can you plz help!! why this isn't workin'?? ( 2 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  3. Calling VB Com Object
  4. Paging using Recordset in ASP
  5. asp tutorial ( 1 Reply )
  6. generate graph from database with ASP
  7. how to check the data stored in database in ASP
  8. Query for updating Records ( 1 Reply )

Post Comments/Questions

In order to post questions/comments, you must be logged-in. If you are not a member yet, then signup, otherwise login. Once you login then come back to this page and you'll see a form right here which will allow you to post comments/questions.

Please note, one of the benefits of signing up is to be notified immediately by email everytime you receive a reply to the thread you have subscribed to.

 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.