 |
 |
 |
 |
    |
|

You can think of the Web as a client-server environment, where Web pages are stored on and retrieved from a server, while the browser on a user's machine is the client. Your Web-based applications must run on the server, the client, or both. As you decide whether to run a server-side CGI or a client-side script, you'll find that each option has advantages and disadvantages.
Dynamic updating and interactivity features, such as validating a data entry field, are best done with a client-side scripting language like JavaScript, which is more responsive and delivers immediate feedback to the user.
However, a client-side script runs only on the user's machine. No information can pass from the client to the server, which you'll need if you want to store information in a server database or run server applications (to automatically generate and send email, for example). Also, if you want to collect information about your Web site's visitors, you'll also have to handle this on the server side.
|
 |









 |
Security also plays a role in your decision to run an application as a client-side script or a server-side CGI. When you run applications on a Web browser, your server is safe because the client application can't access server resources. But a poorly written server-side CGI application can open your site to malicious visitors. For example, if a user enters their name into an HTML form and your CGI prints that name, someone could potentially use that form as a back door to execute their own server commands, such as listing password files. Your CGI has to be vigilant in blocking these sorts of openings.
Another important consideration is the burden that CGIs place on your server. With a server-side CGI, every new request for your CGI program adds to the server's processing load, which can result in lengthy response times if your site enjoys heavy traffic. Client-side scripts obviously don't have this problem.
Basically, if your site has to interact directly with a user, client-side scripts are the way to go. But if you need to store information in a server database or provide customized Web pages, a server-side CGI is usually the better solution.
|