24 Aug Admin
o The World Wide Web is built on a number of different technologies.
o For most users, the web starts and ends with their choice of web browser. The browser is said to define the client-sideof the web, with the browser, the computer it is running on, and the user surfing the web being collectively referred to as the client.
o Consider a client who has decided to visit the web site at www.google.com. The first thing that happens is that the client will make a request to Google’s web server for the default page of that web site.
o The web server is an application running on a computer owned by Google. Like the client, the server application and the computer on which it runs define the server-side of the web, and are collectively referred to as the server.
o When the server receives the request from the client for a particular page, its job is to retrieve the page from the computer’s files and serve it back to the client. In many cases, this operation is a very simple procedure involving little or no work on the part of the server.
o However, using a programming language like PHP, Perl or Java, we can cause the server to either modify the page it finds before it passes it back to the client, or even to generate the page entirely from scratch. This is referred to as a server-side application. The page passed back to the client looks (to the client) exactly the same as any other page that has not been modified.
o An example of a server-side application might be to insert the current date and time into a page. This would mean that each time the page was requested (say, by using the browser’s refresh button), a new time value would be added to the page.
o Once the client has received the page from the server, it displays the page and waits for the user to request another page. As soon as the page reaches this state, it has moved beyond the control of the server. No server-side application can now alter the contents of the page without the client having to make another trip back to the server to get a new (and possibly updated) copy of the page.
o However, all modern browsers allow for the running of clientside applications. These are small applications which are embedded within the HTML code of the page itself.
o Server-side applications ignore any client-side applications that they find while modifying pages to send to the client, so in general the two types of application cannot easily “talk” to each other.
o However, once the client has received a client-side application, it can begin to modify the page dynamically, without the need to go back to the server.
o An example of a client-side application might be a clock on a web page that updated every second.
o An unfortunate side effect of client-side applications is that all the code must be sent to the client for running, which means that the application’s inner workings are available for anyone to see. This makes it impractical for checking passwords, or doing anything else that could cause confidential information to be released into the wild.
o In addition, all modern web browsers afford the user the opportunity to switch off client-side applications altogether. On top of this, the way the same client-side application is run will vary from browser type to browser type.
o Despite these drawbacks, client-side applications (or scripts, as they are better known due to their general brevity) remain the best way to provide web users with a rich environment when developing web applications.
o In short, the two technologies each have their strengths and weaknesses:
o Client-side scripts allow the developer to alter pages dynamically, and to respond to user actions immediately rather than having to wait for the server to create a new version of the page. However, there are security and cross-browser compatibility issues to be aware of, and these are often nontrivial.
o Server-side applications allow the developer to keep her code secure and secret, thus allowing for more powerful applications to be created. In addition, since the server running the code is always a known quantity, applications that run successfully in one browser will run successfully in all browsers. However, despite all this power, there is no direct way for a server-side application to alter a page without having to force the client-side to load another page. This makes it completely impractical for things like drop-down menus, pre-submission form checking, timers, warning alerts and so forth.