Error Handling

Web applications are more complicated than the simple, one-dimensional client requests and server replies in the file model that predominated during the early years of the Internet and the World Wide Web. In those days, the Internet was much like (and was even called) an Information Superhighway. Most websites were like simple billboards that decorated that superhighway.

Times have changed. Processes have become richer and more powerful. In a typical web-centric application, the following sequence of events occurs between the client and server.

1. The client calls the server, requesting a secure connection.

2. The server replies to the client with a session token, allowing a secure, encrypted session to occur between the two.

3. The client passes login information back to the server.

4. The server authenticates the client and replies with a My Page for the client to use.

5. The client fills out a form and submits it to the server.

6. The server checks the form for potential errors. If the form is clean, the server does something with the form, such as calling an external process to order products that the client wants to purchase.

7. The server returns another page to the client, with information on the status of the ordering process.

During this back-and-forth process, problems can arise in several ways:

■ A phone call interruption

■ Loss of a signal from the cell tower

■ Interruption of the session because of a network problem

■ Invalid data on the form the client submits

■ Outdated server SSL certificates

The Android framework and the server's error-recovery mechanisms handle some of these problems automatically, but your code must properly handle many of them. This is one reason why the Android team chose Java as the primary development language for web applications. Java provides a rich and powerful set of features that catch error conditions and provide an easy way of properly handling them.

Server code can also be written in the Java programming language. Indeed, much of the World Wide Web currently uses Java for dynamic server content. Many examples show Java code used for writing applications that run on servers on websites such as IBM's developerWorks. (See the link in the upcoming section "External Links.")

The new field of "cloud computing" attempts to clarify issues for vendors of web applications and client companies. By contracting out web services to cloud computing vendors, the times of peak usage of your web applications can be maximized. When the times where fewer people are making use of your web application, you aren't billed at the same rate and are therefore able to save money.

Many companies are offering these cloud computing services for reasonable, almost utility like-rates, similar to what an electric company or water company would charge. You can find more of this kind of information on the IBM developerWorks website.

0 0

Post a comment