HTML Online Tutorial Contents

Following are the posts for HTML online Tutorial. To learn everything about HTML, just read these posts: HTML Online Tutorial HTML TAGS (2) HTML BASICS (3) HTML ELEMENTS (4) HTML ATTRIBUTES (5) More »

XHTML

XHTML stands for Extensible Hypertext Markup Language. It is also known as XML (Extensible Markup Language). It is a markup language. In XHTML, there are no predefined tags. The user defines the More »

HTML SUMMARY

In this tutorial, you learned: HTML Introduction HTML Tags HTML Basics HTML Elements HTML Attributes HTML Paragraphs HTML Headings HTML Formats HTML Image HTML Links HTML Lists HTML Frames HTML Table After More »

HTML TABLES (13)

HTML Tables are used to arrange data in web pages. HTML allows the use of tables by <table>…</table> tags. Each row in HTML table is recognized by <tr>…</tr> tag. In each row More »

HTML FRAMES (12.2)

Nested frames example: For the following example to work, there are two other simple HTML files : “HMTL11e1 frame a.html” and “HMTL11e1 frame b.html”. your browser will divide your screeub half. The More »

 

Tag Archives: ASP

Learn what are ASP Session Objects and how they are used?

Learn what are ASP Session Objects and how they are used?

In this post you will learn what is session object in ASP and how it is used?

The session object is used to store the information of a user session and to change its settings.

Session is usually when a user opens a particular application on a system, do some alterations on it and then close it. The system that you are using recognizes you and knows when you open and close the application. But, if we look for same recognition of user over internet, then there is a problem, because the web server does not recognize the user and has no information about its activities. This is because the HTTP address cannot maintain state.

So, the solution to this issue is provided by the ASP. It creates a unique cookie for every user and is sent to the system user is using. This cookie contains the information which actually provides the identification of the user. The session object is basically this interface.

In other words, session object is used to store user information and change the settings for the user session. The variables which are stored in a session object contains the information about single user and it can be accessed by every page in a particular application. The information which are usually stored on session variables are name, id and the user preferences. The server will always create a new session object for every user which is automatically destroyed when the session is finished.

Session Start

The session for any user starts at three occasions; when a user has requested the ASP file and the Session_OnStart procedure is included in Global.asa file, when any value is stored in a session variable, when the uses has requested an ASP file, and the <object> tag is used to instantiate an object with session by a Global.asa file.

Session end

Any user session will end if he / she has not refreshed the web page in the application for a given time. This time is usually 20 minutes by default. But for some reason you want to change this wait or timeout interval to short or long period than you have to use the property known as Timeout property.

For example, consider a following example, in which we have set the timeout interval of 25 minutes:

The example below sets a timeout interval of 5 minutes:

<%

Session.Timeout=25

%>

But what if you want to end the session suddenly, then you will have to use the method known as Abandon. Consider the following example:

<%

Session.Abandon

%>

But we do not know when the user is going to end his / her session. The session ending time is unpredictable from the user side i.e. we do not know that the last request of the user was the final request or not. Thus, you do not know how long you need to keep the session alive. If you wait too long for the user to continue the session then it will use more of your resources which is not practical. On the other hand, if the session is stopped too soon than the user might have to start gain because when we stopped the session the server deleted all of the information of user session. Therefore, determining and setting a right timeout interval is a challenge. Therefore, we recommend to only store small amounts of data in the session variables.

In the next post, you will learn how to retrieve, store and remove the session variables. You will also learn how to loop through the content and static object collections.

ASP 11.1

Learn about ASP Session Objects (11.1 ASP):

The object which stores information or change settings of a user session is known as Session Object.

A session is the duration in which user opens an application, performs some changes in it and then closes it. During this session your computer knows everything about the opening of an application, changes you made in it and the closing of an application. But the server does not know anything about the session of an application because HTTP does not keep the information of this sort.

ASP solves this problem by using the interface of Session object. ASP basically creates a special cookie and sends it to the user computer to identify the user. This is known as Session Object.

Session Objects comprises of different variables which store information about the single user. But this information is available to every page of an application. Few common type of information stored in session objects are name, id and the user preferences. But the server destroys the session object after creating a new session object.

You must be wondering when a session starts? The session starts when

  1. any user requests an ASP file and there is a Session_On Procedure in the Global_asa file.
  2. There is any value stored in the session variable.
  3. any user requests an ASP file and there is a <Object>Tag in the Global_asa file to instantiate the session object.

The next question which comes in mind after this is When a session ends? So, the answer is that if the user is not using an application for a default period of time than the session will expire. By default this time is 20 minutes. This time can be changed by using the “Timeout” Property of the session. Following is an example where you can change the default time to 40 minutes:


<%

Session.Timeout=40

%>

But if ending the session immediately is needed then you can use “Abandon“ property of session. Following is the property that shows the syntax to end the session immediately:

<%

Session. Abandon

%>

Now the issue is when to end the session. For example you are using an application for past 20 minutes. Then you stop using it for like an hour. In the meantime this application is using loads of resources on the server for no use. So to reduce the resources, if the server shuts the session like after the 5 minutes( you have not been using the application). Then you would have to start again if by any chance you come back sooner than an hour.  Therefore to find the right time to end the session is quite difficult and unpredictable. So, to avoid this issue we can store few variables in the session object.

The next post will explain about Storing, Removing and Retrieval of session variables. Also it will explain the procedure to loop the content collection and the Static Object collection.

For more visit next posts in this category.To go back to Contents of this tutorial: ASP Active Server Side Scripting Contents

8 asp

Learn about Basic ASP Procedures (8 ASP):

The JavaScript Procedures can be called by using VBScript in ASP. The ASP source codes can include procedures and functions in it. Following is the example that shows the procedures and functions in ASP source code using VBScript:

Example:

<html>

<head>

<%

Sub vbproc(n1,n)

response.write(n*n1)

end sub

%>

</head>

<body>

<p>Result is:<%call vbproc(2,4)%></p>

</body>

</html>

Result:

Result is: 8

 

Following is the example that shows the procedures and functions in ASP source code using JavaScript:

Example:

<%@ language=”JavaScript”%>

<html>

<head>

<%

Function jsproc(n1,n)

{

response.write(n*n1)

}

%>

</head>

<body>

<p>Result is: <%jsproc(2,4)%></p>

</body>

</html>

<script type=”text/javascript”><!–
google_ad_client = “ca-pub-7789281879799866”;
/* webpost */
google_ad_slot = “1930114734”;
google_ad_width = 300;
google_ad_height = 250;
//–>
</script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>

Result:

Result is: 8

Following is another example which shows how to call JavaScript procedures and VBScript procedures simultaneously in single ASP file:

Example:

<html>

<head>

<%

Sub vbproc(n1,n)

response.write(n*n1)

end sub

%>

<script language=”JavaScript” runat=”server”%>

Function jsproc(n1,n)

{

response.write(n*n1)

}

</script>

</head>

<body>

<p>Result is: <%call jsproc(2,4)%></p>

<p>Result is: <%call vbproc(2,4)%></p>

</body>

</html>

 

Result:

Result is: 8

Result is: 8

Some basics about the difference between VBScript and JavaScript:

To call VBScript or JavaScript procedures, you need to use the “call” followed by the procedure name in a ASP file written in VBScript. If you are using the”call” word then you need to use parenthesis for the parameters required by the procedure.  But if you are not using the “call” word then there is no need for parenthesis for parameters. Moreover, if there are no parameters in the procedure then the parenthesis are optional.

It is compulsory to use parenthesis in a ASP file written in JavaScript., when you need to call VBScript or Java

For more visit next posts in this category.To go back to Contents of this tutorial: ASP Active Server Side Scripting Contents

7 asp

Learn about Basic ASP Variables (7 ASP):

As we all know that variable is used to store information. There are different types of variables in ASP.

Something about Variable’s Lifetime:

Those variables which are declared outside the procedure can be easily changed or accessed by using any script in ASP. But those variables which are declared inside the procedure cannot be changed or accessed by any scripts. Because they are created and destroyed every time a procedure is executed.  The main two types of Variables are:

 

Session Variables:


Those variables which store information of only single user but they are available on all the pages in a single application are known as Session Variables. Mostly the type of information stored in these variables is: name, id and preferences.

 

Application Variables:

These variables are also available to all the pages in the application. But they are used to store information of many, in fact, all the users in one particular application.

 

How to declare a text value variable:

Following is an easy example to show how to store a text as a value in the variable:

Example:

<html>

<body>

<%

Dim name

Name=”Tweety”

response.write(“My name is” & name)

%>

</body>

</html>

 

RESULT:

My name is Tweety

 

How to declare a array:

Following is an easy example to show how to store a text as a array:

Example:

<html>

<body>

<%

Dim framename(6),m

Framename(0) = “tweety”

Framename(1) = “sweeto”

Framename(2) = “dan brown”

Framename(4) = “angel”

Framename(5) = “ben ten”

Framename(6) = “lara croft”

For m = 0 to 6

response.write(framename(m) & <br/>)

Next

%>

</body>

</html>

 

RESULT:

tweety

sweeto

dan brown

angel

ben ten

lara croft

 

For more visit next posts in this category.To go back to Contents of this tutorial: ASP Active Server Side Scripting Contents

3 asp

Learn about Features of ASP, IIS and PWS (3):

ASP can provide different features which are:

• You can edit, change or add any content dynamically to your website.
• It responses to different user data and queries submitted by HTML forms on web.
• It can also access databases and return the acquired data to you.

• Your web page can be made more customized which is usually useful for individual users.
• ASP has the advantage of speed and simplicity over CGI and PERL.
• ASP code is invisible (cannot viewed by the browser) and provides high security.
• ASP programming can reduce the network traffic.
• The HTML and ASP files are almost same.
• ASP file can contain all HTML, XML and different scripts in it.
• ASP scripts are only executed on the server.
• The extension of an ASP file is “.asp”.

Following are some features of IIS:

• IIS stands for Internet Information System.
• IIS is a set of Internet based services.
• IIS services are for servers and are created by Microsoft.
• IIS services are for use with Microsoft Windows.
• IIS is available with Windows 2000, Windows XP, and Vista.
• IIS is also comes with Windows NT.
• IIS is the best option for developing and testing different web applications.
• IIS is extremely easy to install.

Following are some features of PWS:

• PWS stands for Personal Web Server.
• PWS is compatible with older versions of Windows 95, 98 and NT.
• PWS is also best for developing and testing web applications, but it is outdated.
• PWS is recommended only for training.

For more visit next posts in this category.To go back to Contents of this tutorial: ASP Active Server Side Scripting Contents