Java Servlets for Web-Based Healthcare Computing Bambang Parmanto, PhD; Xiaoming Zeng, MD; Daniel Pothen, RHIA Java and extensible markup language (XML) are arguably the two most important Internet technologies since the advent of the Web. These two technologies hold the promise of program and data portability using any computing platform or Internet device.1 Both technologies share several important characteristics yet possess many complementary features that together make them a powerful platform for Internet applications.2 Although XML holds much promise for the future, this article will focus on the potential of the lesserknown Java servlet. The article will also discuss the possibility of combining servlet and XML technology for healthcare computing. Java has created much hype in the Internet community with its dancing applets, which can travel all over the Internet to any client computer. Java applets brought dynamic behavior to otherwise static hypertext markup language (HTML) pages. However, the real potential of Java for enterprise computing is not on the client side but, rather, on the server side. Despite the hype, we rarely see Java applets used in Web-based corporate applications today. Instead of Java, HTML remains the universal language for client browsers. This can be attributed to serious shortcomings in applet deployment, including the lack of uniform and up-to-date Java support available from Web browser vendors, the sluggish performance of Java applets, and the slow speed at which applets are downloaded from the Internet. Internet Technologies and Healthcare Computing Three factors should be considered in the decision to adopt emerging technologies for use in the healthcare environment. First, the technology must contribute to lowering the overall costs incurred in the delivery of healthcare services. Second, the technology should offer a competitive advantage. Finally, the technology should have an impact in improving patient care.3 Web-based healthcare applications can potentially bring unprecedented information access to everyone and can provide a unique competitive advantage JOURNAL OF HEALTHCARE INFORMATION MANAGEMENT®, vol. 14, no. 1, Spring 2000 © Healthcare Information and Management Systems Society and Jossey-Bass Inc., Publishers 17 18 Parmanto, Zeng, Pothen while at the same time playing a part in improving patient care. As the patient’s role is transformed from the healthcare receiver to the customer, the demand for more information related to the credibility of the patient’s health plan and the qualifications of their primary care physicians, as well as more in-depth knowledge about prevalent diseases, will increase. Another compelling reason for using Internet technologies is the fact that it is easier and less expensive to develop a system based on Internet technologies than other alternative technologies. This is in part due to the practice of publishing source code on the Internet by skilled programmers, which has resulted in free, very high-quality software. The products of this practice are often more robust than their industrial counterparts. The rise of the Linux operating system clearly illustrates this point. As one of the most promising Internet technologies, Java has received broad support from industry and academia. More and more developers have adopted the Java language as the standard development language. Many Javabased healthcare applications have been developed in the last five years.4 The early enthusiasm of Java’s potential, however, can easily turn into disappointment and even skepticism when Java applet implementation fails to measure up to the hype. One reason for this is that Java applets—the small programs running on the clients’ browsers—have many limitations. For example, contrary to the “write once, run everywhere” hype, applets require users to have certain browsers that run compatible versions of the Java Virtual Machine (JVM), an interpreter that converts Java bytecode into machine language. The advent of Java servlet technology (announced by Sun Microsystems in 1997) saves the Java supporters from despair by delivering Java’s strengths to the server, instead of the client. Until the problems that limit applet deployment are solved, we will see a diminishing role on the part of the client-side Java applet and an increased focus on the significance of the Java servlet. What Is a Servlet? A Java servlet is a server-side application that is platform and protocol independent. The Java servlet is a standard extension to the Java platform that can be used to extend the functionality of the Web.5 Servlets are to the server what applets are to the client—small Java programs compiled to bytecode that can be loaded dynamically to extend the capability of the host server. Just as applets are invoked and loaded by Web browsers, servlets are invoked and loaded by Web servers. Because the servlet does not require a graphical interface, the problems that hamper applet portability can be avoided. Servlets: A Historical Perspective It is easier to view the benefits of servlet technology from a historical viewpoint by comparing it with previous technologies with similar functionality. Common gateway interface (CGI) and the applet are two such technologies. Java Servlets for Web-Based Healthcare Computing 19 Servlet and CGI. At the beginning, the World Wide Web was static, that is, the content of each HTML file remained fixed and unchanged. The Web server was primarily a static file server that stored HTML files and posted the files whenever a client sent a request through the hypertext transfer protocol (HTTP). Functions that require dynamic operation, such as image map and database operation, did not exist. Then came CGI, which brought new life to the Web. CGI is a small program written in a script language (such as Perl) that functions as the glue between HTML pages and other programs on the Web server. With CGI, the Web server can pass certain client requests to an external program. The output of this program can then be sent back to clients as they fetch the HTML file. Therefore, CGI extends the functionality of the Web server. For example, a Web server with CGI can act as middleware by connecting the client’s browser to a database system. Today, CGI is a necessary function of all Web servers. However, CGI has two primary drawbacks that only make it suitable as a temporary solution for server-side applications. The first pitfall is the fact that CGI is not efficient. Every time a Web server receives a request to access a CGI program, it must create a new process to run the CGI program. Then, the Web server will pass to the new process (via environment variables and standard input) every bit of information that might be necessary to generate a response. If the Web server receives a million requests, a million processes will be created. Creating a process for every request requires time and significant server resources. It limits the number of requests that can be handled concurrently by the Web server. The second limitation is that a CGI program cannot interact with the Web server to take advantage of the server’s abilities once it begins the execution because it runs in a separate process. A typical example of this limitation is demonstrated when a CGI script is unable to write to the log file of the Web server. An increasing number of Web developers have adopted servlet technology to perform tasks that were previously accomplished by the CGI script. Unlike CGI, Java servlets handle multiple requests by creating a single process with separate threads using the multithreading feature of Java. Multithreading provides both efficiency and scalability of the servlet. Although servlets are mainly used in the Web server, they could also be used in other types of servers or Internet protocols, such as file transfer protocol (FTP) or simple mail transfer protocol (SMTP, commonly known as e-mail). Servlet and Applet. The basic idea behind how Java applets work is relatively well known in the information technology industry. An applet is a small Java program that can be downloaded and run on client browsers that have JVM. Although the applet is conceptually powerful, its implementation has a few disadvantages. The first problem relates to browser incompatibility. The Java applet runs only on browser versions that are equipped with a compatible JVM version. Considering that older versions of browsers (Netscape and Internet Explorer 3.0) are still available on client computers, applets cannot run everywhere, as was originally promised. Second, applets are not allowed 20 Parmanto, Zeng, Pothen to perform input-output operations on the client machine, which limits the functionality of the applets. Finally, applets are not convenient for the client to communicate with a database because a direct connection between the client and the database server is required. This limits the application of applet technology in serious enterprise environments and is one reason why applets are not widely used in health information system development. Usually the applet is used to present dynamic graphics on the client side, such as a real-time electrocardiogram display.6 In contrast with the applet, the servlet can act as middleware between the Internet client and database server. It establishes a consistent connection with the database server and represents the client’s requests (such as database queries) through HTTP. The client simply sends a request to the Web server and receives a response in the form of an HTML file. HTML is accepted as the standard markup language for display and formatting by almost all types of browsers. If the client requires more complex interaction with the server, it could also employ an applet to communicate with the servlet. In other words, the client is “thinner” in the servlet environment than in the applet solution. Advantages of the Servlet In addition to the advantages discussed in the previous section, servlet technology employs the capabilities of Java, which makes it suitable for network and enterprise computing. Compared with alternative solutions, the servlet is much more powerful.7 Like Java itself, the servlet has a number of benefits as a server-side programming language: Portability. Because servlets are written in Java, they bring Java’s “write once, run anywhere” closer to reality—even more so than the Java applet. Power. Servlets can harness the full power of Java’s application program interface (API): built-in Internet support, multithreading, image manipulation, Java database connectivity ( JDBC), common object request broker (CORBA) connectivity, remote request invocation (RMI), object serialization, and so on. Internationalization. Servlets support international characters (Unicode). Efficiency. Compared with CGI, servlet technology is much more efficient because multiple concurrent requests are handled by one process using separate threads (the multithreading capability of Java). Servlets are compiled into Java bytecode before they are loaded into the server process; therefore they are much faster than common scripting language. Safety and security. Servlet technology supports strong data type, memory management, and excellent exception handling inherited from Java, which makes it less likely to have fatal errors during the execution process. The servlet is capable of using the server’s security manager for the customization and enforcement of a specific security policy. Extensibility and flexibility. More classes can be added to the current API as demand and popularity of the servlet increase. Java Servlets for Web-Based Healthcare Computing 21 Typical Servlet Implementation Basically, servlets dynamically build and return an HTML file based on the nature of the client request. Then they process user input passed by an HTML form and return an appropriate response. A typical use of servlet technology for the enterprise computing environment is in building connections to the database server and retrieving the information for the network clients via JDBC API. JDBC is an API specification that defines a uniform interface for accessing different relational databases. JDBC API uses a driver manager and database-specific drivers to provide transparent connectivity to heterogeneous databases. There are four kinds of JDBC drivers that can be imported by the servlet as a middleware to establish connections to various databases. The Java database connectivity–object database connectivity (JDBC-ODBC) bridge is the most widely used JDBC driver. It provides JDBC access using most standard ODBC drivers to the databases. Figure 1 illustrates this model for the Java servlet in the network database application. A combination of database middleware and intelligent client detection using servlet (see section on JavaXML for portable medical records near the end of this article) increases the accessibility of the database—every client is able to access the database by using virtually any kind of Internet browser. This model will be more applicable in the next-generation Internet (NGI), better known as Internet 2. Internet 2 will increase bandwidth and is expected to be more reliable and provide better quality of service. Therefore, the Internet is expected to be one thousand times faster than it is now. Development of the Servlet The prerequisite for servlet development and implementation is fairly straightforward. Early adopters of servlet technology were usually developers with either Web programming or Java backgrounds. Web programmers use servlets because they possess certain advantages over CGI, whereas Java programmers use servlets for leveraging Java features for server-side programming. Familiarity with both HTTP and Java programming is useful for those who want to write a servlet. The tools needed to develop servlets are the Java Servlet Development Kit (available for free), a Java programming software environment, and a Web server that supports the servlet API. Figure 1. Servlet Database Connection Request Request Servlet Response Client JDBCODBC Bridge ODBC Driver Response Internet Web Server Database 22 Parmanto, Zeng, Pothen Implementing servlet technology is relatively easy. There is no need to purchase expensive new hardware and software. Many Web servers have built-in stand-alone servlet engines for running servlets. Sun’s Java Web server (formerly called “Jeeves”) is written entirely in Java and provides the best support for the servlet. Other Web servers with built-in servlet engines include the W3C Jigsaw server, O’Reilly and Associates’ WebSite Professional, Netscape’s Enterprise Server, and Lotus’s Domino Go. However, as the servlet is relatively new, the majority of Web servers are unable to provide built-in support for the servlet. In this type of situation, addon servlet engines are available for many servers, including Apache, Netscape’s FastTrack Server and Enterprise Server, Microsoft’s Internet Information Server and Personal Web Server, Starnine’s WebStar Server, and so on. Some of the popular servlet engines are the Java-Apache Jserv, Live Software’s Jrun, and New Atlanta’s ServletExec.8 Potential Uses of Servlets in Healthcare Computing The following are some potential uses of servlets in healthcare computing. Healthcare Consumer Informatics. Healthcare consumer informatics is emerging as a new discipline that focuses on providing timely and comprehensive information for users of the Internet. Healthcare providers have to promote their services to these potential customers. On the other hand, healthcare consumers also demand more information to obtain better services. The Internet, thanks to its convenience, becomes a natural place to look. In 1997, 43 percent of adult Internet users searched for health information on-line.9 Not only patients but also physicians, insurance companies, and government officials can be potential consumers of healthcare information. Health information on-line is becoming a hot commodity. Healthcare Integration. Networking and personal computers have created an increasingly distributed clinical computing environment tailored to specific user needs. The distributed computing approach has been considered advantageous because it allows departments or branch organizations to select computing systems that best meet departmental needs. The downside of this popular approach is that the systems become fragmented and the clinical, as well as administrative, data elements are scattered across many “islands” of data. An important benefit of the electronic health record is the ability to create a comprehensive view of patient care, which translates into better-quality healthcare and more efficient delivery of care. This benefit requires an integrated patient record compiled by gathering data from islands of medical record elements. Integrating clinical and administrative data sets from various sources in a single institution has been a slow and difficult process for most healthcare providers. Combining data sets from many institutions is even more challenging, but this is exactly what is happening as healthcare institutions consolidate Java Servlets for Web-Based Healthcare Computing 23 to form an integrated delivery network. An integrated healthcare delivery system may consist of very diverse institutions, ranging from tertiary medical centers, community hospitals, and clinics to home healthcare, hospices, rehabilitation centers, and physician practices. These different patient care settings will undoubtedly have different legacy systems that do not “talk” to one another. Discarding all of these different systems and replacing them with a single platform usually is not an option. Despite the considerable investment required, many institutions undergoing consolidation consider information technology as a strategic tool in the integration process. The World Wide Web is considered the technology that offers most of the tools needed for integration.10 Servlets provide effective programming tools necessary for integration. The servlet is mainly used in conjunction with the HTTP that forms the backbone of the Web. Combining the servlet with other enterprise programming technologies, such as CORBA, RMI, Java Server Page, and JavaBeans, provides the effective programming tools necessary for integration of different proprietary systems. An n-tier system with servlet technology as the middleware to combine data from various sources can be developed. The complexity of the system is hidden from the end users. Because the servlet is portable and can coexist with any system, it can be used as the glue that integrates all data elements from various sources in the enterprise. The integration can be carried out with minimal disruption to existing computing facilities. There is no need to make any modifications on the client computers, since the Java servlet is the program running on the server side. Servlet plus XML Equals Portable, Intelligent Medical Records. Problems associated with browser compatibility that hinder applet implementation also plague Web-based health information system implementation using CGI. The design of the system usually assumes that users have certain versions of browsers available. This assumption has lead not only to user frustration but also to ineffective Web-based health information system deployment. For example, a physician attempts to access a database via a Web connection. Shortly thereafter, the physician receives a message that reads “Please use Internet Explorer 4.5 or Netscape Navigator 4.0 or above.” If Netscape Navigator 3.5 is installed on the physician’s computer, what can the physician do? Go to Netscape’s Web site, spend more than an hour downloading the newest version of Netscape Navigator, and wait? In most situations, the physician will quickly become annoyed and cancel the operation. Inspired by the idea of “canopy computing,”11 we have embarked on a project that aims to develop a canopy for the rain forest of healthcare computing. This project has two broad goals. The first goal is to develop a portable patient record system that is capable of handling multimedia contents. A portable patient record will allow for the seamless exchange of data between any system connected to the Internet, and a multimedia-capable system will allow integration of data elements that are currently scattered across many 24 Parmanto, Zeng, Pothen systems. XML provides the foundation for this system. The proposed system will also offer system-level portability because the entire system, including the Web server, will be written purely in Java and will be easily portable to different operating systems (portable data, portable program). The second goal is to develop a patient record system that is intelligent enough to automatically detect the type of browser and Internet device used by the client, in order to provide personalized information to users. This is an important feature needed in Internet 2, where everyone will be connected to the Internet from their home, office, car, and hotel room using various Internet devices, via a wire or wireless connection. The Java servlet will be used to develop the intelligent middleware, and extensible stylesheet language (XSL) will be used to tailor the presentation stylesheets. The architecture (portrayed in Figure 2) consists of the following main components: Patient record stored as an XML document. The record will be managed using an XML-based record management system. Interfaces with legacy systems can be developed to convert data elements in those systems to the XML-based patient repository. Figure 2. Java Servlet and XML for Intelligent, Portable Medical Record System Laptop Palmtop (Wireless) XML-based Patient Record Java Servlet Middleware HTTP Protocol Personalized Presentation Internet Graphic Workstation Web Server XSL Style Sheet Collection Network Computer PC Using Old Browser Java Servlets for Web-Based Healthcare Computing 25 Presentation database. The presentation database is a collection of stylesheets in XSL12 format that define how the patient records are presented in different browsers to different users. A table that matches browser types, user profiles, and stylesheet presentations is also a critical part of the presentation database. Java servlet application. This is the core program, which handles many important functions, such as processing user requests, selecting the kind of presentation that should be used, and determining how to deliver the information to the client (in HTML format, XML format, or together in XML and applet format). Clients. The clients consist of different Internet devices running different types and versions of browsers. The Internet devices used by clients will include: handheld (palmtop) computers running the HandWeb browser and Microsoft Pocket Internet Explorer over a wireless connection, ordinary desktop or network computers running various versions of Web browsers, and powerful graphic workstations running the latest browsers (XML capable). To illustrate how the system functions, it is best to use a series of clientserver exchanges: 1. An HTTP request is submitted from the client to the Web server. In its message header, the HTTP request contains crucial information for automatically determining the browser and client (computer) profiles. 2. Based on the browser profile and user authentication, the Java servlet program will determine the user profile: the type of device and browser being used and who the user is. 3. The servlet selects an XSL stylesheet that matches the user profile from the presentation database. The servlet also loads the patient record by constructing a patient record object in Java from the XML record using either the W3C standard Document Object Model interface or the more lightweight Simple API for XML. 4. The servlet will decide how the information will be delivered and presented to the user. Here are a few possible scenarios: • If the client is not capable of processing XML data, the servlet will transform the patient record to a plain HTML format and send it to the client. • If the client is XML capable, the data will be sent in XML format. • The server can also support other devices, such as cellular phones and pagers, as well as future Internet devices. 5. The client receives the information, presents the information, or conducts further processing (transformation, addition, updating, deletion, and so on). Conclusion Java servlet technology will play an important role in the industry’s continued efforts to integrate healthcare information systems. The benefits of portability, flexibility, and efficiency of servlet technology make it an ideal platform for 26 Parmanto, Zeng, Pothen server-side development. Servlets deliver the promised benefits of the Java platform more successfully than the much-hyped Java applets. We expect to see the servlet emerge as an increasingly popular server-side development tool, replacing the older CGI. The capabilities of the servlet, combined with the complementary advantages of XML to describe information content on the Web, make the servlet a viable option for creating a portable and intelligent electronic patient record system. References 1. Bosak, J. “XML, Java, and the Future of the Web.” [http://www.xml.com/xml/pub/w3j/ s3.bosak.html]. Oct. 1997. 2. Fuchs, M. “Why XML Is Meant for Java.” Web Techniques Magazine. [http://www. webtechniques.com/archives/1999/06/fuchs]. July 1999. 3. Elliott, J. “Nine Hot Technology Trends.” Healthcare Informatics, Feb. 1999, pp. 81–110. 4. Mittman, R., and Cain, M. “The Future of the Internet in Health Care: Five Year Forecast.” [http://www.chcf.org/conference/forecast.pdf]. Jan. 1999; Wilkerson, J. D., and others. Competitive Managed Care: The Emerging Health Care System. San Francisco: Jossey-Bass, 1997; Zuckerman, A. E. “Using the Java Language to Develop Computer-Based Patient Records for Use on the Internet.” Proceedings of the 1996 AMIA Fall Symposium, 1996, 772–775; Kohane, I. S., and others. “Building National Electronic Medical Record Systems via the World Wide Web.” Journal of the American Medical Informatics Association JAMIA, 1996, 3, 191–207. 5. Sun Microsystems. “Java Servlet API: The Power Behind the Server.” [http://www.javasoft.com/ products/servlet/index.html]. 1999. 6. Wang, K., and others. “A Real Time Patient Monitoring System on the World Wide Web.” Proceedings of the 1996 American Medical Informatics Association Fall Symposium, 1996, 608–612. 7. Hunter, J., and Crawford, W. Java Servlet Programming. O’Reilly & Associates, 1998; Callaway, D. R. Inside Servlets: Server-Side Programming for the Java Platform. Reading, Mass.: Addison-Wesley, 1999. 8. Callaway (1999). 9. Mittman and Cain (1999). 10. Cimino, J. J., Socratous S. A., and Claton, P. D. “Internet as Clinical Information System: Application Development Using the World Wide Web.” Journal of American Medical Informatics Association, 1995, 2(5), 273–284; McDonald, C. J., and others. “Canopy Computing: Using the Web in Clinical Practice.” Journal of the American Medical Association, 1998, 280(15), 1325–1329. 11. McDonald and others (1998). 12. XSL working draft. [http://www.org/TR/WD-xsl]. Apr. 21, 1999. About the Authors Bambang Parmanto, PhD (parmanto@pitt.edu), is assistant professor of health information management and biomedical informatics at the University of Pittsburgh. Xiaoming Zeng, MD (xizst9@pitt.edu), is a doctoral student in the Department of Health Information Management, University of Pittsburgh, and fellow at the Center for Biomedical Informatics, University of Pittsburgh Medical Center. Daniel Pothen, RHIA (djpst38@pitt.edu), is database analyst with Cogent Healthcare, Inc., of Laguna Hills, California.