Many dynamic web applications, especially those that access databases based on user input, need to be on the server. Typically, these have been implemented using a Common Gateway Interface (CGI) application. Using, for example, Sun's JavaServer, such programs can instead be implemented with the
The advantage of a Java servlet on servers with lots of traffic is that they can execute more quickly than CGI applications. Rather than causing a separate program process to be created, each user request is invoked as a thread in a single daemon process, meaning that the amount of system overhead for each request is slight.
The following tips are a quick guide for developers starting out building servlet applications. They are based on the use of the popular IBM VisualAge tool.
1. Pick the latest version of VisualAge for Java possible when developing servlets, and always apply the latest fix packs.
2. Use the Enterprise version of VisualAge for Java if you are planning on delivering Java applications for you company. The Professional edition is a good choice if you are just beginning to learn Java.
3. Export your servlet application packages to an external directory for testing.
4. Remember to specify URLs correctly qualifying packages names in web apps. Use a period, not a forward slash.
5. Use the best web server engine test environment possible. The latest version of IBM WebSphere matches the support in VisualAge for Java and your other development tools.
6. Build your application as Java beans. A "beans" approach brings several advantages to your applications: separation of the business logic from the interfaces, easy access for reuse to all your business logic and the thousands of classes in Java and the ability to build "smart" components that reduce development by an order of magnitude.
7. Build the interface to your applications using servlets. Servlets provide a simple "message based, client-server" common interface to your applications.
8. Leverage the power of DB2. It has very robust support for integrating applications and transactions using stored procedures, reliable application messaging, distributed data access and object store.
9. Build the web interface to your servlets using Java Server Pages. JSP is a scripting language for incorporating Java beans into web pages.
10. Expect more from your tools and yourself. With Java, there are many facets of development that are under your control.
About the Author
From "Servlets Part 2: Understanding Java servlets and putting them to work" by Jim Mason, AS/400 Experts Journal, Vol. 3, No. 2, March/April 2000. Provided courtesy of The 400 Group.
For More Information
- What do you think about this tip? E-mail us at editor@searchDatabase.com with your feedback.
- The Best DB2 Web Links: tips, tutorials, scripts, and more.
- The Best Java Web Links
- Have an DB2 or Java tip to offer your fellow DBA's and developers? The best tips submitted will receive a cool prize--submit your tip today!
- Ask your technical DB2 or Java questions--or help out your peers by answering them--in our live discussion forums.
- Check out our new Ask the Experts feature: Our DB2 gurus are waiting to answer your toughest questions.
This was first published in November 2000