Client-Side Versus Server-Side Programming

Team-Fly    

Macromedia® DreamWeaver® MX Unleashed
By Matthew Pizzi, Zak Ruvalcaba
Table of Contents
Chapter 21.  Working with CGI and Java Applets


Having explored the power of JavaScript behaviors and Flash using Dreamweaver, you may be asking why you would want to use server-side programs (within which I include both CGI and application servers). Indeed, some tasks could be done either on the client or on the server. For example, validating a form to ensure that the user enters the correct data could be done using JavaScript or a server-side program.

The Advantages of Server-Side Programs

There are some tasks that can be done only on the server. You do not want and cannot give every person who uses your Web site direct access to your databases. Database requests are filtered through the Web server so users see only the data that you want them to see.

Server-side programming enables you to save bandwidth. By filtering records and requests at the server, you just send subsets of 10 or 20 records instead of thousands of records. Nor do you need to send enough HTML, JavaScript and Flash code to cover every operating system/browser combination just what is required for the particular client that has requested the page.

Even tasks that can be done on both the client and the server such as form validation have advantages when done on the server.

Processing of programs on the server allows for platform independence the CGI script sends plain HTML to the client, and you do not have to rely on features that will work only in, for example, Internet Explorer version 4 or demand that JavaScript is enabled in the browser. Remember that some users, particularly those within security-conscious organizations, such as banks or insurance companies, may have browser features such as JavaScript, Java, and ActiveX controls turned off.

Server-side programming allows a wider range of clients particularly thin clients such as PDAs and embedded devices to be supported by your Web site. You don't have to rely on any client-side processing.

NOTE

The enormous popularity of the Internet has led to an explosion of devices that can connect into it. Originally, you needed to have a computer to hook into the Internet. Now you can use mobile phones, PDAs such as Palm Pilots, and TV sets. Even household devices can be connected up for remote control, remote servicing, or for your fridge to tell you when it has run out of milk (and order it itself!). These devices, which do not have much computing power themselves, are collectively known as thin clients. Thin clients are likely to have small, specialized operating systems and just enough power to carry out a limited number of tasks.


A major advantage of server-side processing that leads many organizations to adopt it is security. Because all the processing is done on the server, the client sees only the results of the process, not the processing itself. You do not have to expose your code as you do when using JavaScript. Information that hackers could find useful, such as field and table names or database paths, remain hidden.

For example, if you had to verify a password using JavaScript, the user could find out what password you were expecting by simply viewing the source code.

Advantages of Client-Side Programming

Server-side programming is extremely useful and the best solution in some situations. However, there are still many advantages to client-side programs. There are some things that can be done only on the client especially when manipulating the user interface. It would be impractical to have to make a call to the server to simply stop or pause a video frame. Mouseover effects, animation, and interaction with the user can be done only using client-side solutions.

One of the problems of server-side programming is that you need to have permissions to configure and manipulate the Web server. By default, Web servers do not allow programs to run on them, unless they are specially configured to do so. If you do not have these permissions (for instance, if you are renting Web space from an ISP), you may need to look for client-side solutions to provide the functionality you want.

Client-side scripting also relieves the server of routine tasks that the browser is quite capable of doing. For instance, today's client-side image maps are much better than the early server-side image maps that made Web servers very slow.

NOTE

You should, if possible, use the browser to check forms. You can use the Validate Form behavior to do this. Of course, you may encounter browsers that have limited capabilities and do not support JavaScript, so you also use a server program to check the form from these browsers.


Most important, client-side scripting is much faster than server-side scripting imagine the page having to make a new request to the server each time an image is rolled over on your page. Dynamic HTML and Flash both take advantage of this to give much richer user interfaces and almost instant response to user actions.


    Team-Fly    
    Top


    Macromedia Dreamweaver MX Unleashed
    Macromedia Dreamweaver MX 2004 Unleashed
    ISBN: 0672326310
    EAN: 2147483647
    Year: 2002
    Pages: 321

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net