What Is a Dynamic Web Page
Total Page:16
File Type:pdf, Size:1020Kb
Dynamic Web Pages
Brad Polzar Computer Science / Software Engineering University of Wisconsin – Platteville [email protected]
Abstract
As the world becomes more and more global, the demand for state-of-the-art online technologies becomes more and more pertinent. In particular, companies and organizations are demanding more and more services from their web pages. Whether it’s e-commerce, data storage, or attracting and navigating visitors through a site, web pages have had to become dynamic in structure. No longer will the basic HTML tags suffice for a web site.
This paper will discuss some of the various technologies and uses of dynamic web pages including Client- and Server-side scripting including Active Server Pages and JavaScript, as well as briefly touching on other technologies for creating dynamic web content such as Flash and Java Applets.
Polzar 1 CS 4110 Introduction
What is a Dynamic Web Page?
A dynamic web page is any web page that reacts to a human user’s actions. These actions coupled with conditions that are currently met will determine what actions are taken by the web page. Sometimes this will result in the server sending a different page while at other times it will show an animation on the current page. This can, however, lead to a contradiction as any hyperlink can accomplish the same effect. The main distinction is that the decisions on what to display will be made dynamically.
Types of Dynamic Web Pages
Dynamic web pages can be divided into three groups: Server side pages, client side pages, and imbedded pages.
Server Side Pages
These pages are ran on the server when the page is requested. The server will decide exactly what to send the client based on what information was included in the request and what conditions are met at that time. A server side page handles the dynamics of a web page from page to page. Uses for server side pages are great and range from e-commerce sites to online email accounts and many more [1].
Coupled with the great number of uses, server side pages can use a variety of technologies to display the page. Microsoft’s Active Server Pages (ASP) and ASP.Net and Hypertext Preprocessor (PHP) give a lot of power to developers of all gambits.
Client Side Pages
Client side dynamic web pages are run on the client’s computer. They will handle various actions that occur inside of the web page rather than between pages [1]. Two common actions of client side pages are animations and form verification.
Unlike server side pages, client side pages are much more limited in technology possibilities. JavaScript is the dominant client side scripting language [5].
Imbedded Pages
Polzar 2 CS 4110 Some web pages have dynamic content such as Macromedia Flash movies and Java applets imbedded into them. These will be considered imbedded pages. The power of these pages comes from the abilities of the technology used. Games, movies, and more can be created using these types of technologies.
Server Side Pages with ASP
Since web pages that are dynamic on the server have more options for implementation, there is a wider array of technologies that can be used. Active Server Pages and Hypertext Preprocessor both have their pros and cons, but in capabilities, they are very similar. Therefore, ASP will be discussed in more detail with the knowledge that PHP has similar features except where noted.
Languages in Active Server Pages
Active Server Pages provide a shell for a scripting language to run in to perform the various tasks of the web page. According to Mitchell, four scripting languages can be used: VBScript, JavaScript, Python, and PerlScript [1]. Microsoft’s Jscript can also be used. In ASP.Net, the .Net languages can be used as well, giving developers even more power [4].
This is one area where PHP differs, however. PHP comes with its own scripting language which is very similar to the C languages and Java.
Running a Server Side Script
When a web page that has some server-side script is requested on a server, it is not sent to the client as is. Rather, the server processes the code, converts it to basic HTML, and then sends the page to the client. To look at how a page is evaluated, we must first look at the structure of a page [1].
Server side code is intermixed into normal HTML. The appendix, which gives the code to create a visual calendar of the current month, shows how the ASP code can be dispersed among the HTML tags. The ASP code can be identified by the surrounding < % and %> tags. The server will process these blocks of code as it gets to them in the page source [1].
Active Server Page Objects
There are a number of objects that come with Active Server Pages that allow developers to perform various tasks on the web page [1].
Polzar 3 CS 4110 Table 1: ASP Object Descriptions [1] Response Object Deals with the response from the server to the client. Can write HTML to page, create cookies, and set out properties dealing with the response to the client. Request Object Handles the information that the client sent with the web page request. Includes cookies, and form information. Session Object Holds information of client’s current session on the server. Is deleted after a period of inactivity on the website by the user. Application Object Keeps the state of the server. Only one instance. Used for global data that is changed often. Server Object Provides basic properties and methods to used such as setting the timeout length. ASPError Object Allows developers to see more information about ASP script errors. Object Context Used to link ASP and the Microsoft Transaction Server. Object
These objects are a part of ASP and can therefore be used in conjunction with any of the scripting languages (or programming languages if using ASP.Net) [1, 4].
Uses of Server Side Scripting
In general terms, server side scripting is used to show a customized web page for each user. One of the biggest uses for server side scripts is e-commerce. Server side scripts allow a shopping cart to be updated, credit card information to be obtained and used, and recommendations be made based on past purchases. Keeping this information would be impossible otherwise.
Being able to access databases is another useful ability. As the world becomes more global, people want to be able to access information from a variety of places. ASP can connect to any database that is OBC compatible, which is most of the databases today [1].
On a smaller scale, however, server side scripts can also make basic decisions on what to show a user. Whether it’s showing a calendar of the current month or the most recent post on a message board, the server can determine what to show automatically.
Client Side Scripting
Many times, however, a web page needs to take some sort of action after it has already been sent to the client. The server cannot control this anymore as the page being viewed is no longer on the server [1]. This is where client-side scripting comes in.
Polzar 4 CS 4110 Unlike writing scripts for a server, writing client-side scripts has little options for languages. Most of it is done in JavaScript, but Jscript is becoming almost identically compatible. The reason JavaScript is so prevalent is that when Netscape developed their browser, they only made it compatible with JavaScript which they had developed. Microsoft had their own scripting language as well: VBScript. But they made Internet Explorer capable of using both VBScript and JavaScript. Thus, web developers wrote client side scripts in JavaScript as both major browsers supported it [5].
Uses of Client Side Scripting
Client side scripting is used for handling any action that takes place inside of a web page [1]. The actions that can invoke a script vary from filling out a form, moving a mouse over an object, to loading the page even [5].
One very common use for client side scripting is advertisement banners; they are also a very good example of what can be accomplished with client-side scripting. Many of the ads have an animation to attract attention. Most of the animations will play automatically. Some are user controlled, though. The most common of these is the game where the user can win $1 million or an iPod.
Another useful ability of client-side scripting is the ability to do simple verification of form information. Checking whether required fields are filled in or making sure that a field has the proper number and type of characters entered [5].
Location of the Scripts
Unlike server side scripting, the location of client side scripts can vary [5]. One place to put the script is right inside the HTML code. Using the script tags, a developer can place his code right there. This puts all of the code on one page and for simple scripts this is usually fine.
However, it can be easily seen that these scripts can get amazingly complex. Putting all this code in the page can make the source hard to read, though. Therefore, JavaScript allows the scripts to be located in another file. Then, there is only a call to the code in the web page rather than the entire script [5].
Other Dynamic Utilities
The technologies that have been discussed thus far have been entirely implemented by writing code into the HTML page or writing it in another file. Two other methods of
Polzar 5 CS 4110 making web sites dynamic involve including other objects into the web page: Java Applets and Flash files. Java applets are Java programs written to be included in a web page. They allow for the power of Java to be included with a web page. With Javascript and Flash technologies, however, they do seem to be as prevalent in the web world.
Flash is developed by Macromedia and allows developers to create movies that can be included in a web page. With ActionScript, it also allows developers to create programs to run on the web site. The programs can be just as complex as a client-side script, but are entirely contained in the flash file. Many introductory web site movies are created using this.
One downfall with either of these technologies, however, is that they are entirely contained within a single page. It is impossible to change pages and keep the applet or flash program running.
Conclusion
The world-wide web has become an integral part in all of our lives. Without the technologies of Dynamic Web Pages, however, this part of our lives would be lost. Whether it’s customizing a web page based on a user’s previous visits or just making things move around on the screen as the page opens, the power of Dynamic Web Pages has allowed this information age to quickly become global.
References
[1] Mitchell, S. and Atkinson, J. (2000) Sams Teach Yourself Active Server Pages 3.0 in 21 Days. Indiapolis: Sams.
[2] Achour, M., et al. (2007) PHP Manual. http://www.php.net/manual/en/.
[3] w3schools.com. (2007) ASP Tutorial. Retrieved March 5, 2007 from http://www.w3schools.com/asp/default.asp.
[4] Wikipedia.org (2007) ASP.Net. Retrieved March 5, 2007 from http://en.wikipedia.org/wiki/ASP.NET.
[5] Flanagan, D. (1998) JavaScript: The Definitive Guide. Sebastopol: O’Reilly.
Polzar 6 CS 4110 Appendix Sample ASP Code
<% Language = VBSCRIPT %>
'Determine the current month and year Dim curDate curDate = Date()
'Create an array to hold the 42 possible days of the month Dim CalArray(42)
'Find the first weekday of the month Dim iFirstWeekday iFirstWeekday = DatePart("w", DateSerial(Year(curDate), _ Month(curDate), 1))
'To find the num of days in the month, get the date of the day ' before the first day of the next month iDaysInMonth = DatePart("d", DateSerial(Year(curDate), _ Month(curDate) + 1, 1-1))
Dim i For i = 1 to iDaysInMonth CalArray(i + iFirstWeekday - 1) = i Next
'Create an html table to represent the calendar Dim iRows, iCols iCols = 7 iRows = 6 - _ Int((42 - (iFirstWeekDay + iDaysInMonth)) / 7) %>
" Response.Write CalArray((row - 1) * 7 + col) Response.Write "" Response.Write " | " Else Response.Write "" End If Next |
<% 'Returns the name of the month designated by the ordinal month iMonth Function GetMonthName (iMonth) Select Case iMonth Case 1: GetMonthName = "January" Case 2: GetMonthName = "February" Case 3: GetMonthName = "March" Case 4: GetMonthName = "April" Case 5: GetMonthName = "May" Case 6: GetMonthName = "June" Case 7: GetMonthName = "July" Case 8: GetMonthName = "August" Case 9: GetMonthName = "September" Case 10: GetMonthName = "October" Case 11: GetMonthName = "November" Case 12: GetMonthName = "December" Case Else: GetMonthName = "**INVALID MONTH**" End Select End Function %>
Polzar 8 CS 4110