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)

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. Moreover if your browser More »

HTML FRAMES (12.1)

A container window which can display a web page is known as Frame. Each frame can display separate HTML document. A webpage can be divided into many frames, each displaying different HTML More »

 
asp 11.2

Learn about ASP Session Objects (11.2 ASP):

Just for revision, the issue discussed in previous post was 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 theserver 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.

By using ASP we can store various variables in the sessions. Following example will set the variable name to “RABIA” and age to “22”.

<%

Session(“name”)=”RABIA”
Session(“age”)=22

%>

These or any values stored in session variables can be accessed from any page in an application. Following will print the values of variables:

<%

Response.Write(Session(“name”))

Response.Write(Session(“age”))

%>

The above code will give following output:

RABIA 22

The user preferences are very significant. They can be stored in the session variables. Later on, these preferences can be used to decide what page should be send to user according to his/her preference. Following is the example which shows the text version of page and message that is going to be displayed if the screen resolution is high:

<%

If Session(“screenres”)=”high”

Then

%>
Displaying the multimedia version due to high resolution
<%Else%>
Displaying the text version due to low resolution

<%End If%>

Removing the variables:

All session variables are inside the content collection. Any of these variables can be removed by using “Remove method”. Following example will delete the session variable name if the age is greater than 92:

<%
If Session.Contents(“age”)>92 then
Session.Contents.Remove(“name”)
End If
%>

Removing each variable one by one can be troublesome. So to avoid this “RemoveAll” method can be used as shown in the following example where all variables are removed:

<%
Session.Contents.RemoveAll()
%>

Similarly displaying the variables one by one can be troublesome, so to avoid this using loop to see all the contents collection is possible as shown in following example:

<%
Session(“name”)=”RABIA”
Session(“age”)=22

dim m
For Each m in Session.Contents
Response.Write(m & “<br />”)
Next
%>


This will give the following output:

Name

Age

For instance you do not know the number of variables in the session object then you can use the following example to loop through the content collection:

<%
dim m,s
s=Session.Contents.Count
Response.Write(“Session variables: ” & s)
For m=1 to s
Response.Write(Session.Contents(i))
Next
%>

This will print all the variables as follows:

Session variables: 2
RABIA
22

To see that all values are stored in session objects, loop through the staticobject collection is possible. Following is the example that shows how it can be done:

<%
dim m
For Each m in Session.StaticObjects
Response.Write(m)
Next
%>

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.

ASP Cookies

Learn about ASP Cookies (10 ASP):

A cookie is basically a small file which is embedded on the user computer by the server to identify the user. This cookie is send with every request that user make for a particular page using any web browser. One of the many advantages of ASP is to both retrieve and create different cookie values. Following is the brief method of crating cookies in ASP:

The command that is used to produce cookies is:    “Response.Cookies”. This command should be written before the HTML tags in the file. (<html>).  The syntax for creating cookies is following:

<%

Response.Cookies”name of cookie”=”value of cookie”.

%>

There are different properties that any cookie can have for example the expiry date of the cookie.  Following is the example where a cookie named “website-school” is created with the value “ASP Tutorial” and will expire on 03/01/2012:

<%

Response.Cookies” website-school”=” ASP Tutorial”.

Response.Cookies” website-school”=” ASP Tutorial”.Expires=#January 03,2012#

%>

Now comes the part where you get to learn how to get the cookie. The command which is used to retrieve any created cookie is “Request.Cookies”. You can request the value of cookie and store it in a variable (Cookievariable) and then print it later. Following is the syntax used for this purpose:

<%

Cookievariable=Request.Cookies(”name of cookie”)

Response.write(”name of cookie” & Cookievariable)

%>

The following example will retrieve “website-school” and print its value:

<%

Cookievariable=Request.Cookies(”website-school”)

Response.write(”website-school” & Cookievariable)

%>

Output of this example will be:

website-school = ASP Tutorial

 

Now, some information about cookies with keys….

If any cookie comprises of more than one value, then such cookie is known as a cookie with keys. The syntax for doing so is:

<%

Response.Cookies(”name of cookie”) (“sub name”)=”value of cookie”.

Response.Cookies(”name of cookie”) (“sub name1”)=”value of cookie”.

%>

Following cookie will display cookies with keys of a user containing his name, age and sex:

<%

Response.Cookies(”user1”) (“name”)=”Muntaha”

Response.Cookies(”user1”) (“age”)=”22”

Response.Cookies(”user1”) (“sex”)=”Female”

%>

Reading all cookies send by a server will be very troublesome. Don’t worry there is a solution  to read all the cookies send by a server. But to do this we will use Request.Cookies.HasKeys property.  Following is the syntax to do this:

<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>

<html>
<body>

<%
dim a,b
for each a in Request.Cookies
response.write(“<p>”)
if Request.Cookies(a).HasKeys then
for each b in Request.Cookies(a)
response.write(a &b& “=” & Request.Cookies(a)(b))
response.write(“<br />”)
next
else
Response.Write( “Start”)
end if
response.write “</p>”
next
%>
</body>
</html>

The output of this code will be as following:

Start

user1:name=Muntaha
user1:age=22
user1:sex=Female
Some of the browser does not support cookies. Then passing information via these browser is impossible. So the two alternative ways of passing information are:

  • You can either add Parameters to the URL.
  • Or you can use a form to do so

 

By using the forms, user can enter the information and then clicks the “Send” button. Following is the way with which you can add parameters to the URL:

<form method=”post” action=”none.asp”>
user Name: <input type=”text” name=”name” value=”" />
user age: <input type=”text” name=”age” value=”" />
<input type=”submit” value=”Submit” />
</form>

Similarly the retrieval of these cookies can be done in following way:

<%
name=Request.form(“name”)
age=Request.form(“age”)
response.write(“<p>” & name & ” ” & age & “!</p>”)
%>

Similarly the information can be passed by adding parameters to the URL.

<a href=”none.asp?name=Muntaha & age=22″>Go to none Page</a>

The retrieval of these cookies can be done in following way:


<%
name=Request.form(“name”)
age=Request.form(“age”)
response.write(“<p>” & name & ” ” & age & “!</p>”)
%>

 

9.2 asp

Learn about Basic ASP Forms and Inputs by User (9.2 ASP):

Just for revision:

Request.From:

It is a command which is used to get values in a form by using “post” method. The information which is sent by a form using get method is not available to everyone. This information also has no limits on its amount. The difference is that if the user would have typed “you” and “angel” in the HTML form then the URL sent to the asp server would be:

http://www.website-school.com/formex.asp

But if the file has asp scripts:

<body>

Hey

<%

Respone.write(request.form(“myname”))

Respone.write( “ “ &request.form(“mynames”))

%>

</body>

The internet browser will display:

Hey you angel

 

Following example shows how to use post method and Request.Form to interact with user:

Example of a Form by using Request.Form and “post” as a method:

<html>

<body>

<form action=”form_requeryzx.asp” method = “post”>

Name: <input type = “text” name = “myname” sixe = “12”/>

<input type = “submit” value = “submit”/>

</form>

<%

Dim myname

Frame=Request.Form(“myname”)

If myname<>””Then

Response.Write(“Hello” & myname & “/<br/>”)

Response.Write(“Whats up dude”)

End if

%>

</body>

</html>

Following example shows how to use radio buttons and Request.Form to interact with user:

Example of a Form by using Request.Form and radio buttons:

<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>

<html>

<%

Dim bikes

bikes=Request.Form (“bikes”)

%>

<body>

<form action=”form_radiobt.asp” method = “post”>

<p> Please select high quality bike:</p>

<input type = “radio” name = “car” />

<% if bikes = “Honda” then Response.Write(“checked”)%>

Value = “Honda”>Honda</input>

<br/>

<input type = “radio” name = “car” />

<% if bikes = “Yamaha” then Response.Write(“checked”)%>

Value = “Yamaha”>Yamaha</input>

<br/>

<input type = “submit” value = “submit”/>


</form>

<%

If bikes<>””Then

Response.Write(<p> Your high quality bike is: & bikes & “/<p>”)

End if

%>

</body>

</html>

The Form Validation:

It is compulsory for user input to be validated on the internet browser whenever it is possible. The Browser validation is easier, faster and decreases the load on the server.

If the user input is entered into the database then you should consider the matter of validation. The best way to validate a form is to post the form to itself rather than going to different page. In this way user will get the error message on the same page as the form. Thus finding the error will be much easier.

 

9.1asp

Learn about Basic ASP Forms and Inputs by User (9.1 ASP):

In HTML form we can use Request object to retrieve information from different forms. Following is the example of HTML form:

Example of HTML form:

<form method = “get” action = “formex.asp”>

Nameone: < input type = “text” name “myname”/>

<br/>

Nametwo: < input type = “text” name “mynames”/>

<br/>

<input type = “submit” value = “submit”/>

</form>

 

There are two commands which are used to retrieve user input from forms. These commands are:  Request.QuerryString and Request.Form

Request.QueryString:


The Request.QueryString is the command which is used for the retrieval of values in a form by using “get” method. The information which is sent by a form using get method is available to everyone. This information also has limits on its amount. The difference is that if the user would have typed “you” and “angel” in the HTML form then the URL sent to the asp server would be:

http://www.website-school.com/formex.asp?myname=you&mynames=angel

But if the formex.asp contains asp source code script:

<body>

Hey

<%

Respone.write(request.querystring(“myname”))

Respone.write( “ “ &request.querystring(“mynames”))

%>

</body>

As a result the output would be:

Hey you angel

Example of a Form by using Request.QueryString and “get” as a method:

<html>

<body>

<form action=”form_requeryz.asp” method = “get”>

Name: <input type = “text” name = “myname” sixe = “12”/>

<input type = “submit” value = “submit”/>

</form>

<%

Dim myname

Frame=Request.QueryString(“myname”)

If myname<>””Then

Response.Write(“Hello” & myname & “/<br/>”)

Response.Write(“Whats up dude”)

End if

%>

</body>

</html>

Request.From:

It is a command which is used to get values in a form by using “post” method. The information which is sent by a form using get method is not available to everyone. This information also has no limits on its amount. The difference is that if the user would have typed “you” and “angel” in the HTML form then the URL sent to the asp server would be:

http://www.website-school.com/formex.asp

But if the file has asp scripts:

<body>

Hey

<%

Respone.write(request.form(“myname”))

Respone.write( “ “ &request.form(“mynames”))

%>

</body>

The internet browser will display:

Hey you angel

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

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

 

 

6 asp

Learn about Basic ASP Syntax Rules (6 ASP):

This basic tutorial will include examples of ASP code, which will make learning ASP easy for you. To Practice either copy them or try to create similar codes on your own and then run them.

How to write an output to the Internet Browser:

Just like a HTML file, ASP file can contain HTML tags in it. The ASP file can also contain some Server Scripts in it which are enclosed in <% and %> known as delimiters.


These Server Scripts are included to be executed on the Server. They can contain expressions, procedures, statement and phrases which are valid for scripting languages you prefer to use.

Write Command:

The write command (response.write) is specifically used for writing an output to a browser. Following is an example which sends the “My first text” to the browser.

Example:

<html>

<body>

<% response.write(“My first text”)%>

</body>

</html>

There is another shorthand way to do this. This shorthand way is shown in following example:

Example:

<html>

<body>

<% =“My first text”%>

</body>

</html>

 

Using Scripts in ASP

VBScript:

Several Scripting Languages can also be used in ASP. But the default scripting language is VBScript. Following is an example which sends the “My first text” to the browser using VBScript:

Example:

<html>

<body>

<%

response.write(“My first text”)

%>

</body>

</html>

 

JAVA Script:

As JAVA Script is not the default scripting language, so you need to set it as a default at the top of a particular page in the language specification. Another important advice is: JavaScript is case sensitive, so write your ASP code with uppercase. You should only use lowercase when it is required by the language. Following is an example which sends the “My first text” to the browser using JAVA Script:

Example:

<%@ language=”JavaScript”%>

<html>

<body>

<%

response.write(“My first text”)

%>

</body>

</html>

 

Moreover the ASP is usually used with JavaScript and VBScript. But if your requirement is to use other scripting languages like PERL and REXX. Then you need to install their script engines separately.

5 asp

Learn about Installation of IIS on Windows Server 2003 and Testing your Web (5 ASP):

 

Follow these steps to install IIS on your Windows Server 2003:

 

  • When you open the Windows Server 2003, there is “Manage Your Server Wizard”.
  • Sometimes, the server is not displayed, then go to “Adminstrative tools” and select the “Manage your Server”.
  • The wizard will open, in this wizard, click “Add or remove a Role”.
  • Then click on “Next”.
  • In next window click “Custom Configuration”.
  • Then click “Next”.
  • Then select “Application Server Role”.
  • Then click “Next”.
  • If the wizard asks for CD of Server 2003, then insert the CD and run the setup till it is finished.
  • The wizard will display that Application Server Role is installed.
  • To open the “Application Server Management Console (MMC)”, click on “Manage this Application Server”.
  • Then open the Internet Information System Manager, then expand the desired server, then open the websites folder.
  • Then you will see default website which should not say “stopped”.
  • Finally IIS will be running.
  • Then, in the Internet Information System Manager, click the “Web Service Extension Folder”.
  • This will show the default configuration of IIS, in which Active Server Pages are blocked.
  • Then Allow the Active Server Pages.
  • Congratulations!!!!!! You have successfully activated ASP………..:)

 

For this installation of IIS and PWS is necessary. If you have already installed IIS and PWS then proceed. Otherwise check the previous posts for the easy tutorial of installation of IIS and PWS. Follow these steps test your web:

 

  • Find the folder “Inetpub” on your Hard Drive.
  • Open this folder and find another folder named “wwwroot”.
  • Then create a new folder named “Mywebsite” in this “wwwroot”.
  • Open the notepad and write some asp code in it.
  • Save this file as “aspfile.asp” in the new folder.

  • Then check whether your server is running or not.
  • If yes then open the browser and type in the address bar http://localhost/Mywebsite/aspfile.asp.
  • You will successfully view your asp web page.
  • Congratulations :)
4 asp

Learn about Installation of IIS and PWS (4 ASP):

Any one can run ASP on their own Personal Computer just by using Windows PC as a Web Server. This requires installation of either IIS (Internet Information System) or PWS (Personal Web Server). IIS and PWS are available as free web server components with Windows.

Compatibility of IIS:

• IIS 7 is compatible with Windows Vista Business
• IIS 7 is also compatible with Windows Vista Home Premium.
• PWS and IIS is not supported by Windows Vista Home edition.
• IIS 5.1 is available with Windows XP Professional.
• PWS and IIS is not supported by Windows XP Home edition.
• IIS 5.0 is available with Windows 2000 Professional.
• IIS 3 and IIS 4 are supported by Windows NT Professional.
• PWS and IIS 3 are supported by Windows NT Workstation.
• PWS is supported by Windows 95 and comes with Windows 98.

 

Installation of IIS on Windows Vista:

Follow these steps to install IIS on your Windows Vista:

• Open the Control Panel.
• Open the Programs and Features.
• Click on “Turn Windows Features on or off”.
• Select the option of Internet Information system and click “OK”.
• Install all patches for bugs and security problems.
• Then run Windows Update.

 

 

Installation of IIS on Windows XP and Windows 2000:
Follow these steps to install IIS on your Windows Vista:
• Open the Control Panel.
• Open “Add or Remove Programs”.
• Click twice the “Add/Remove Window Components”.
• Click “Internet Information system”.
• Click its details.
• Select “World Wide Web Service”.
• Click OK.
• Then in Windows Component, Click “Next”.
• Install all patches for bugs and security problems.
• Then run Windows Update.

 

 

Installation of PWS on Windows 95, Windows 98 and Windows NT:
Follow these steps to install PWS on your Windows 98:
• Open the folder named “Add-ons” on your windows CD, Open the PWS folder and run the “setup.exe” to install PWS.

 

Follow these steps to install PWS on your Windows 95 and Windows NT:
• You have to download “Windows NT 4.0 Option Pack” from Microsoft.
• Then install PWS.