JavaServer Pages
resources.
The transient nature of CGI programs also limits what they can do, at least without help.
The shopping cart is a classic example of this. Clearly, a shopping cart will need to
remember which items a user has selected, but it cannot do this alone if it is going to
evaporate after each item is added. In more technical terms, CGI programs are stateless,
meaning that they cannot keep track of any data between requests. Most CGIs get around
this problem by saving all necessary information to a database before they exit, but this
can be slow and requires that the connection to the database be opened each time the
program is started.
Perhaps the most serious problem with CGIs is the way they mesh presentation with logic.
As noted, the presentation of a page is expressed as HTML and is typically written by
designers and/or expert HTML authors. Program logic, such as what to do on a stock
page if the requested ticker symbol does not exist, lives in the program code and is
written by programmers. Despite exceptions to this division of labor, both HTML coding
and programming are generally such complex and specialized activities that it is rare to
find someone skilled at both.
The problem here is that at some point, the HTML must be incorporated into the program
because ultimately, the program must generate the output; in order to do this, the program
must have all the HTML that will go on the page. This is bad for both the programmers
and HTML authors. When the design changes or new pages are designed, the HTML
authors cannot change the HTML directly because it is buried in the program. They must
present the new designs to the programmers, who must then incorporate the changes into
their code without breaking any functionality. The HTML authors must then try out the
program to ensure that the HTML that comes out is identical to the HTML that went in,
and so on. Hours of company time can be lost this way, and animosity can all too
frequently develop between the programming and production groups.
addressed in a number of ways.