Monday, November 7, 2011

Static and Dynamic web pages

We can broadly classify web sites and web pages into two categories:

1. Static web pages
2. Dynamic web pages

Static Web Pages



A static web page is a page which has the same content always.

In case of static web pages, content is written in the page itself as plain html. Until the author of the web page updates the content, the content remains the same in the static pages.

Static web pages are meant for providing information which does not change often. For example, visithttp://www.google.com/intl/en/about.html. This page is a static page. The content is always the same (until they update the content by uploading a new html file to the web server).

HTML files are used to create static web pages.

Dynamic Web Pages



Dynamic web pages get content from database. Content is NOT hard-coded in the page itself.

Dynamic pages are created using "serverside code" when the page is loaded every time.

An example for a dynamic page is this tutorial page itself. See the file name in the URL. The file name is "Tutorial8.aspx". We have used only one file to display any tutorial chapter. The chapter number is there as part of the URL (the chapter number is 8 for this chapter).

When you type the URL in the browser, this page is dynamically created from database, based on the chapter id in the URL. The content of each chapter is stored in our database, not in the file itself. When you access the page, our server side code will check what is the TutorialId in the URL. Based on the TutorialId, it will retrieve appropriate chapter content from the database and dynamically create the web page. (You can try to change the TutorialId in the URL to some very large number and try. The page will give an error because our code will fail to get the corresponding chapter content from the database). This entire site has only very few files (like index.aspx, Tutorial.aspx etc)

Dynamic web pages are created using technologies like ASP, ASP.NET, PHP etc.

HTML pages cannot be dynamic. All HTML files are static pages. If you want to write dynamic pages, you must use some technologies like ASP.NET.

0 comments:

Post a Comment