Java™ 2 Primer Plus
By Steven Haines, Steve Potts

Table of Contents
Chapter 26.  Web Architecture

JavaScript is a Java-like language that runs inside the browser on the client's computer. Because JavaScript doesn't have access to the data that is stored on the server, it is limited in the types of chores that it can do for us. One task that JavaScript excels in is simple data validation. This validation is composed of two types. The first is the traditional validation, where the script is able to determine that you have entered in a wrong number or letter in an input field. The second validation approach is to place only valid choices in a list box or check boxes so that it is physically impossible for the user to enter data that is not valid.

JavaScript code is transported via HTTP along with the rest of the Web page's HTML. When the browser loads the page into memory, it notices the existence of JavaScript calls in the HTML and creates branching operations so that the Web page behaves correctly.

Because the JavaScript code is uncompiled, it can be sent as plain text, which means that it can be generated dynamically by a servlet or JSP. This provides a powerful addition, but not a substitute for, other technologies like servlets and JSP. The primary advantage of JavaScript is in the performance of the system. The ability to do some validation on the browser relieves the network of some traffic and offloads your server, too. The end result is a net speed increase from the user's point of view and a reduced cost of operation for the server. Figure 26.8 shows the software layers on the client side with JavaScript enabled.

Figure 26.8. JavaScript provides programming logic that runs in the browser.


The existence of JavaScript doesn't change the layout of the server-side, however, because either servlets or JSPs can generate HTML that contains JavaScript.


    Java 2 Primer Plus
    Java 2 Primer Plus
    ISBN: 0672324156
    EAN: 2147483647
    Year: 2001
    Pages: 332

    Similar book on Amazon © 2008-2017.
    If you may any questions please contact us: