Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 27. Creating Web-Based Applications Using Java Servlets

Chapter 27. Creating Web-Based Applications Using Java Servlets

So far, all of the examples we have developed have been stand-alone applications, meaning the application is run on the same machine on which it resides. This is fine for personal use-type programs or applications that are shared among a local group of colleagues, but what happens if you develop an application that will be widely disseminated and/or used on different, remote computer platforms. All of sudden you are faced with accessibility, maintainability, and version control issues.

Anyone who wants to use the application will either have to install it on his or her own computer or have direct access to a computer on which the application is installed. This raises a security concern in that it might be undesirable to give users direct access to the server on which the application resides. When the tool is updated, an updated version will have to be sent to everyone having an interest in using it. Further, there is no way of knowing if everyone is using the same version of the tool. Software maintenance and version control become a problem.

The advent of the Internet has provided a way around all these problems. You can deploy a scientific or engineering analysis program as a web-based application. A single version of the application exists on a central server. Any number of client machines can access the tool by connecting to the server via a web browser. The application is easier to update and maintain. When a new version of the tool is developed, it only has to be updated on the server. Every client machine is, therefore, assured of using the latest version. Security is enhanced in that users are not given direct access to the server. The front-end to the tool is implemented as a GUI on the client web browser providing all of the benefits that a GUI provides.

In this chapter we will look at how you can turn a Java program into a web-based application using Java servlets. We will discuss what a servlet is and go over step-by-step how to write one. This chapter will be similar to Chapter 26 in that it will give a broad overview of the process of developing Java servlets without providing comprehensive coverage of the subject. There simply isn't room in this book to explore all the possibilities of servlets and web-based Java programs. For a detailed look at all the ins and outs of Java servlets, consult Inside Servlets: Server-Side Programming for the Java™ Platform by Dustin Callaway.

The specific topics we will discuss in this chapter are—

  • Web-based application basics

  • Java servlets

  • Required libraries and tools

  • Example: a web-based atmosphere modeling tool

  • HttpServlet class

  • General form of an HttpServlet subclass

  • Extracting input parameters

  • Running server-based applications

  • Sending output back to the client machine

  • The AtmServlet class

  • Deploying the web-based application


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint