Server-Side Java

Server-Side Java

Java is a new programming language that is often used to create platform-independent GUIs that a user can interact with in complex and sophisticated ways. However, Java applets—the bits of code that are transmitted over the Internet and executed on the user’s machineare only one side of the whole Java story. This section will focus on the server side of Java.

Java applications that execute on the server are called servlets, and they have their own standard API specification that has now been widely implemented in web server extension products known as servlet runners (such as Apache’s Tomcat server). Servlets are useful in developing web-enabled, Solaris-based enterprise applications.

Increasingly, applications in the enterprise are being implemented using web interfaces, partly in response to the persistent heterogeneity of computing platforms within organizations that span cities, states, and even nations. Accepting platform diversity does not mean losing control of standards, however. Sun Microsystems has pioneered a platform-independent programming language in which applications run on top of a logical Java Virtual Machine (JVM) that presents a consistent API for developers. Most major hardware platforms and operating systems now have virtual machines implemented, including (obviously) Solaris. In fact, the Solaris JVM produced by Sun has been highly optimized in its production release series. JVMs have also been integrated into popular web browsers, so that Java programs can be downloaded from a server and executed within these browsers. (HTML has an <applet> tag that facilitates this process.) Applets have increased the complexity of web-based user interfaces from simple arrays of buttons and forms to dynamic interaction with the user in a way that is similar to a normal desktop application.

Although Java has been successful in improving the client side of web-based computing, it has been slower to make an impact on the server side (this is as much a result of the excitement surrounding applets as any deficit in the servlet API). However, many people believe that the server side is where Java has its greatest potential. The notion of having platform-independent enterprise applications that run through a standard web interface promises to change the way that users, developers, and software interact. The “write once, run anywhere” philosophy means that servers with totally different operating systems and hardware can be replaced with newer systems, without concern for application stability and porting. Commonly used Java classes can be bundled as beans that can provide rapid implementation for a client’s business logic. Full access to the Java API and database servers is also provided for Java servlets, using the Java Database Classes (JDBC) supplied by Oracle and other major vendors. These features ensure that today’s Java server-side programs will not become tomorrow’s legacy applications.

How does server-side Java compare to web-based client/server techniques such as the combination of a Common Gateway Interface (CGI) and a non-object-oriented language such as C? Although a compiled language like C is faster on a byte-per-byte basis than an interpreted language like Java, performance increases for Java can be gained by the combination of optimizing “just-in-time” (JIT) compilers for specific platforms and by reducing the process and memory overhead associated with the CGI. For example, if you wrote a search application in Perl that was accessed by 1,000 web users per hour, that would mean an extra 1,000 invocations of Perl that the server has to deal with, unless a specialized module was used. Of course, if you are running on an E10000, this would probably result in a negligible system strain. For other systems, invoking a Java servlet that occupies only a single process after being loaded into memory, and which persists across sessions, is both memory and process efficient. Servlets are therefore more appropriate for applications that are constantly being executed by multiple users, by taking advantage of Java’s multithreading and synchronization capabilities.

On the flip side, CGI programs are often better suited to single-user, infrequently used, and numerically intensive applications that might only be invoked once per hour. In addition, CGI programs written in C are logically isolated from each other in the server’s memory space: if Java servlets are executed using a single instance of a service manager (for example, Live Software’s Jrun), an unhandled exception arising from malformed or unexpected input could potentially impact all servlets running through the manager, especially if the JVM crashes.



Part I: Solaris 9 Operating Environment, Exam I