Overview of ClientServer Programming on the Web

 <  Day Day Up  >  


Overview of Client/Server Programming on the Web

When it comes right down to it, the Web is just a form of client/server interaction. Typically, Web browsers make requests of Web servers to return a file that is sent back and displayed in the browser. In this basic scenario, a Web server simply acts as a file or server that delivers files or associated error messages, usually in HTML or XHTML format, to a Web browser, as shown here:

click to expand

As introduced in the last chapter, thinking about the Web as a static medium is somewhat limiting, and does not enable you to take advantage of the potential for interactivity. The most basic form of interactivity on the Web, beyond link selection, is filling out a form to be processed by a program running on a Web server. The way a user interacts with a server-side program is relatively easy to describe. First, the user requests a dynamic page or fills out a form to perform a task, such as ordering a product. The request is sent to the Web server via HTTP (Hypertext Transfer Protocol), which runs a server-side program CGI program, that then outputs information ( generally HTML or XHTML) to return to the Web browser. This process is shown here:

click to expand

When described this way, the Web begins to look more and more like a client/server application environment.

Given the previous diagram, you might have two questions. First, where should the programming happen? And second, what technology should it use? On the early Web, the browser tended to do very little computing. It was responsible only for rendering pages on the screen. Now, with the rise of client-side technologies such as JavaScript, plug-ins, ActiveX, and Java applets, it is possible to perform a great deal of computation from within the browser. Put all the pressure on the server, and it may get bogged down, or the user may get frustrated with poor responsiveness. Yet doing most of the computing on the client side may result in compatibility problems given the wide range of browsers out there.

The best solution is a mixture: some things are better suited for the client while others are better suited for the server. For example, it makes sense to use a client-side scripting language such as JavaScript to check the contents of a form before it is submitted to a server-side program, rather than have the server-based program check the data and have to round-trip over the network just to deliver an error message. However, you still would want to check the data at the server side for users who are running older clients or who have turned off client-side scripting. Remember, on the Internet things often go wrong, and users don't always have the best browser with all the right settings. And, of course, you still would want to check whether a malicious user has deliberately sent your program bad data. Yet in the case of connecting to a database, you almost always want to use server-side technology to improve security. Animation makes sense on the client and not the server, while sending an e-mail message makes sense via the server more than the client. In most situations, it is pretty obvious which to choose, but there are occasionally situations in which both client and server-side programming could be used.

Now that we see the balance between server and client-side programming, you still must choose among many competing technologies. The decision isn't easy; there are many choices, as listed in Table 13-1.

Table 13-1: Web Programming Technology Choices

Client-Side

Server-Side

Helper programs

CGI programs

Browser objects
               Netscape plug-ins
             ActiveX cntrols
             Java applets

Web server API programs
                 Apache modules
               Java servlets

Client-side scripting
               JavaScript
               VBScript

Server-side scripting
             Server-side Includes (.shtml)
             ASP or ASP.NET (.asp/.aspx)
             ColdFusion (.cfm/.cfmx)
             PHP (.php)
             Java Server Pages (.jsp)

What's interesting about the numerous technologies available for Web programming is that developers often focus too much on one technology or one side of the equation (client or server) rather than thinking about how the applications they are trying to build will work. This limited focus should be avoided at all costs, if possible, to ensure that you find the correct mix of technologies. This chapter looks at the server side of the equation; subsequent chapters focus on the client side.



 <  Day Day Up  >  


HTML & XHTML
HTML & XHTML: The Complete Reference (Osborne Complete Reference Series)
ISBN: 007222942X
EAN: 2147483647
Year: 2003
Pages: 252
Authors: Thomas Powell

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