dcsimg

What does Dynamic Web Application Really Mean ?

By ServerWatch Staff (Send Email)
Posted Aug 23, 1998


Noppadol Weerakitti
Having a web site is not a big deal. You can hire students from a university to do the work. To be honest, some students can do very good work for less expense. However, what happens after you have a web site is really a big deal.

To make you have a clear picture of the difference between a normal static web site and a dynamic web application, I will use a Telephone Book application as an example.

A static web page Telephone book is just simply created with pure HTML which combines data and "decoration" in the same file.

Click Here to jump to a sample static Telephone Book web page and Here to a dynamic one. You can see that both of them look the same to the user view. However, there's a big difference from the administration view.

For example, adding new staff to the sample static Telephone Book is not a simple task. Why? Because the page lists the staff information in two different colors which makes the code of the page look look this:

<tr bgcolor=#FFFFCC>
<td>Angsana Narksang</td>
<td align=CENTER>1728</td>
<td align=RIGHT>Accounting</td>
</tr>
<tr bgcolor=#FFCCCC>
<td>Buncha Sangdee</td>
<td align=CENTER>1734</td>
<td align=RIGHT>Purchasing</td>



The above code tells the browser to display the data row by row in different colors like this:

Angsana Narksang
Buncha Sangdee

Because the rows have to be sorted by name, then a new staff name Aumaporn Buawlert has to be inserted between Angsana and Buncha. The new page should be like this.

Angsana Narksang
Aumaporn Buawlert
Buncha Sangdee
Having a web site is not a big deal. You can hire students from a university to do the work. To be honest, some students can do very good work for less expense. However, what happens after you have a web site is really a big deal.


All right, that means you have to change the color of all rows after Buncha and do it again and again when a new staff is added to the page. Not a good way, isn't it ?

How about the dynamic page ? Oh, it's a lot easier. Let's take a look at the code that generates the page:

<% Do Until RS.Eof % >
<% index = i Mod 2
<% If index = 1 Then
Response.Write "<tr bgcolor="#FFFFCC">"
Else
Response.Write "<tr bgcolor="#FFCCCC">"
End If % >
<td>
<%= RS("FirstName") % >&nbsp;<%= RS("LastName") % >
</td></tr>
<% i = i+1
RS.MoveNext
Loop % >


Hey, don't worry about the code. It's just syntax. Look at the idea behind it first, OK.


The combination of HTML (black color) and Active Server Pages script (blue color) shown above is the main part which will produce the same result as the static page. OK, let's see what it really does.

First of all, all required rows of data will be generated as a Recordset, in this example called RS which is the result of the query "SELECT * FROM Tel_Book". In another words RS is a collection of all records in Tel_Book table. (Although, the code for generating the Recordset is not shown here, it's just 2 or 3 lines of coding)

After having a Recordset, it is used in the "For" loop to produce rows of records that are placed inside the HTML table.

For the "decoration", the script checks the value of a variable named index and changes the row's background color to either "#FFFFCC" or "#FFCCCC". This can make sure that any change in data will not cause any effect in the colors or vice versa, like the static page. And as you may know, this brings our application close to the basic principle of Object Oriented Programing or OOP, in some sense. And more than that, to add the new record is much easier than painfully editing the HTML file manually like you have to do with the static web page.

You can do it on our Example Page by just simply clicking the ">Add new staff" button located at the end of the table and fill in the form. After that the new staff name will be inserted into the page automatically, in the right position, right color and ... right time. Try it now!


With the same idea, you can add more functions to the page, for instance, editing the existing record, deleting the record which is ju1st a piece of cake.

And that's it. Dynamic Web Application.

Page 1 of 4


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.


 

 


Thanks for your registration, follow us on our social networks to keep up-to-date