Why Use Server-Side Scripting?

I've been doing web sites since 1999. The sites I'm currently doing are the following::

The sites I worked on in the past include (all have undergone substantial change since I worked on them):

All of these site initially involved only HTML, CSS, and occasionally some client-side JavaScript. This is typical for small sites. Over time I've added some server-side scripting to some of the pages. What are the circumstances under which one might want to add server-side scripting?

  1. Present content in web page that is already contained in a database
    1. If the changes to the information are infrequent, e.g. only several a day, then manually changing the information in the page is feasible, but requires more labor and runs the risk of inconsistencies between the web page and the database. Examples would be the www.stanfordclubs.org/dc/listmembers.asp which lists the current members of the organization. This information exists in an Access database for other reasons.
  2. Information entered on a web page will result in various operations - e.g. changes to a database, creation of invoices, emails to the user. It will often be cheaper and more error free to do this via server-side scripting rather than having an employee manually change the database, generate an invoice, or send an email. An example would be ordering a book from a website reduces the available inventory of the book, creates an invoice, and sends an email to the purchaser.
  3. Distributed creation of content for web pages
    1. With static pages, content has to flow through a webmaster who creates/modifies the page and uploads it to the server. Some HTML editors (e.g. Macromedia's Contribute) attempt to allow a number of people to create and upload pages within a template controlled by the webmaster. With server-side scripting and access to a database on a server, multiple users can enter information in a web-based form, that information is then automatically entered into a database, and that information is then retrieved from the database to display the page the user sees.

      For the Stanford club site, I've done a partial implementation to present information from an Access database However, I haven't yet added a web interface to put information into the Access database, and in particular the insertion of links, HTML formatting, or images may be difficult. There's a web-based tool called Joomla that provides for distributed creation of content.
    2. A similar example is a discussion board where the contributions of a number of people are immediately available for everyone to see. (e.g. www.billpegram.com/discuss/)
  4. You want to hide scripting code from user (e.g. for proprietary reasons or to password-protect certain pages)
    1. Client-side scripting code in page can easily be viewed
    2. If any external JavaScript files are referenced, the URL of the JavaScript file can be entered into the location bar of the browser and the external JavaScript file will be displayed (if the reference is a relative-reference, the absolute reference can be easily deduced. Absolute references that begin with a / (what Dreamweaver calls site-root relative references) just requires the user to determine what the site-root is.
    3. An example of where this could be useful is where you want to password-protect certain pages.
  5. Some things are easier to do with server-side scripting rather than client-side scripting - e.g. if you want to pass information from a form on one page to another page, you can do this with client-side scripting, but you have to use client-side JavaScript string methods on the second page to parse the information (e.g. from the query string ) whereas ASP provides a method Request.QueryString() for that purpose.
  6. Looping capabilities in script as opposed to manual generation - The new non-profit sent me a draft questionnaire that they want to implement via a web-based form, with each question calling for a response on the same 5-point scale (so the same 5 radio buttons for each question). Thus the only thing that would differ is the question and the name given to each of the radio buttons in the 5-member group. If the questions were put in a database, then server-side scripting could loop through, writing out the questions and giving each group of radio buttons a unique name. If the user's responses are then sent to the same database, one already has the questions and possible answers in the database.

Revised: August 12, 2010. Comments to William Pegram, bill@billpegram.com