Maintaining Web Publications at Ohio University

Using Java on Web Pages


Return to Appendix IV


What about CGI and JAVA?

When you work with a programmer on a web-based project, there are two possibilities: the program may be executed on the server or on the browser.

Server-based Execution

The program may be executed on the server, with the web browser providing the user interface. This is routinely provided under the name "CGI scripting."

CGI scripting works well in a situation that will involve a modest number of simultaneous browsers. If too many people run the program at the same time, the server system will be brought to its knees, slowing down or even preventing the presentation of other web pages from that server.

The CGI program may execute on the server with the identity of the web server, in which case it will have access to a great many files on the system. In such a case, there will need to be appropriate precautions to ensure the integrity of the system.

The CGI program may execute on the server with the identity of the individual authorized user who wrote it. In this case, the CGI program will have access to all files on that server that are owned by that user, including any personal E-mail files that are kept on that system.


Browser-based Execution

The program may be executed on the browsing computer. This is available with some recent browsers using Sun Computer's "JAVA."

JAVA has the advantage over CGI that the available resources for executing the program grow in exact proportion to the number of people running it, instead of being constant.

The disadvantages of JAVA include the following:


Limited Universality

Browsers run on all sorts of hardware and software, so providing access to the intended functionality will depend on the availability of a JAVA-capable browser for the particular hardware and operating system that the user already has on his or her desktop. Many people will continue to use pre-JAVA versions of browsers because they have too little RAM or because they only have free access to the old version. Visually impaired people are much more likely to use Lynx, which does not include JAVA.


Limited Security

JAVA is a real programming language. An evil JAVA program could be embedded in a page that you innocently browse to. Such an evil JAVA program could, for example, erase your entire hard disk right then, or it could modify the system startup files so that the hard disk got erased the next time you start the system. It could also send copies of all your data files to someone else on the network, one at a time, while you continue to browse. There is no obvious limit to the mischief that could be done with JAVA.

If the browser has been flawlessly written, it will enforce limitations on the running program ("it has to play only in its own sandbox") to prevent the JAVA program from doing anything nasty. Many people who have JAVA-capable browsers will configure them to leave JAVA turned off because they don't trust the browser to be bug-free. This is a realistic fear: at least one version of Netscape's Navigator and at least one version of Microsoft's Internet Explorer have been released that permitted a JAVA program to erase files from the user's hard disk.


Limited Performance

Translating program source code (ASCII text strings) into machine language instructions (binary code) can be done in advance ("compiled"), at execution time ("interpreted"), or partially in advance and completed at execution time ("pre-interpreted"). These three strategies differ in their efficiency as measured by execution speed of the program, in their portability among hardware and software environments for program development, and in their portability among hardware and software environments for program execution.

JAVA can be either interpreted or pre-interpreted. This has made it possible to produce JAVA program development environments for many platforms, and to produce JAVA execution environments for many platforms, but it does slow down the execution speed. This shortcoming is being reduced by speed increases in personal computers and by growing sophistication in the JAVA software, but it will always be an issue for some applications.


How does JAVA Work?

The HTML file can contain either the source code for the JAVA program (enclosed in a <SCRIPT> block) or the file on the server containing the JAVA program can be referenced by a special tag (<APPLET CODE=AppletName.class>) identifying its URL.

More information about JAVA is available on-line:

If the source code is part of the HTML, then the browser must be able to interpret that source code so as to execute the program.

If the program is referenced by a URL, that file must be brought down through the network from the server and executed.


Return to Appendix IV


Ohio University Front Door |Webauthors Welcome| Academic Technology



Dick Piccard revised this file (http://www.ohiou.edu/pagemasters/memo85/java.html) on March 9, 2000.

Please send comments or suggestions to acatec@www.ohiou.edu.