| By Chad Darby | Article Rating: |
|
| September 1, 1998 12:00 AM EDT | Reads: |
43,545 |
In the February 1998 issue of JDJ (Vol. 3, Issue 2), I presented a three-tier database application that used Java servlets. In this article you will learn how to build a three-tier database application that allows a Java applet to perform two-way communication with a Java servlet. I'll focus on the concepts and techniques of applets communicating with servlets, building on the application presented in the previous article. Don't worry if you missed that article; a review follows.
Reviewing Our Student Tracker Application
The previous article presented a three-tier database application that used Java servlets and the Java Database Connection (JDBC). That application allowed a public speaker to keep track of students who attended the seminars. Students interacted with the application by entering their contact information into an HTML form. Once the form was submitted, the Java servlet used JDBC to store the student information in a database. Afterwards, an updated student list was generated by the servlet and returned to the user as an HTML page.
The application was partitioned into three tiers: user interface layer, the business rules layer and the DataStore layer. Figure 1 illustrates the design.
The first tier is a Web browser, which serves as our universal client. In the first phase of the application, an HTML front end was used for user input and to display the database query results. The HTML approach was taken because it lowered the requirements of the client's Web browser version. This low-tech approach made the application accessible to users whose browsers were not Java 1.1 enabled.
The second tier of the application was implemented with a Web server capable of executing Java servlets. The Java servlet harnessed the power of JDBC to access the database to store/retrieve information as needed. A dynamic HTML page was generated by the servlet based on the database results.
The third tier was composed of our back-end database server, which stores the information used by the application. Thanks to the JDBC API, however, the servlet can access the database in a portable fashion by using the SQL call-level interface.
Developing an Applet Front End
To enhance the student tracking system, we will develop an applet front end. Students can now enter their contact information into a Java dialog box. Also, an updated student list is displayed in a Java list component. Figure 2 shows the new applet front end.
Applet-Servlet Communication with HTTP GET and POST
In the previous version the HTML form was used to submit the student's data to the servlet. Accessing the form data on the server side was simple and straightforward. This was accomplished by calling the method HttpRequest.getParameter(
Published September 1, 1998 Reads 43,545
Copyright © 1998 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Chad Darby
Ch‡d (shod) Darby is a Java consultant for J9 Consulting, www.j-nine.com. He specializes in developing server-side Java applications and database applications. He also provides Java training for Learning Tree International.
![]() |
Ravi kumar 02/08/05 06:48:47 AM EST | |||
it is good way of sending objects to the servlet Thanking u |
||||
![]() |
xm 06/07/04 03:21:22 AM EDT | |||
I have applet running on Apache server, using Tomcat to support servlet. I want the applet to transfer a object to the servlet with some parameters, then servlet transfer back the object with new parameter to applet and show on the web site. But where shall I put this class? as the student class you used in your example. WHere do you put it? Thanks for your kind reply in advance |
||||
![]() |
Frederic 05/19/04 04:59:01 AM EDT | |||
Hi, I read your article on the applet servlet communication which was very useful for me to understand the mechanism of the communication. I''m especially interested in sending/receiving serializable objects. The example in the article is quite clear but i juste have one remaining question. In the example, the applet receives a vector of students from the servlet. So the Student class has to be both on client and server side ? How can we do this ? Where should i locate the class to be seen everywhere i need ? Thank you, Frederic |
||||
- Book Excerpt: Introducing HTML5
- It's the Java vs. C++ Shootout Revisited!
- Patterns for Building High Performance Applications
- OpenXava 4.3: Rapid Java Web Development
- Asynchronous Logging Using Spring
- Java for Programmers (2nd Edition)
- Cross-Platform Mobile Website Development – a Tool Comparison
- Write Once Run Anywhere or Cross Platform Mobile Development Tools
- Three Buzzwords That Every CIO Hears but One They Should Listen To
- Immersing into JavaScript Frameworks
- Workday Reportedly Prepping to Go Public
- Book Review: Sams Teach Yourself Java in 24 Hours
- Book Excerpt: Introducing HTML5
- Adobe Sends Flex to the Apache Foundation
- Five Years Waiting for JRE 7: Is It Justified? (Part 1)
- Book Excerpt: Java Application Profiling Tips and Tricks
- i-Technology in 2012: Five Industry Predictions
- It's the Java vs. C++ Shootout Revisited!
- Patterns for Building High Performance Applications
- OpenXava 4.3: Rapid Java Web Development
- The Next Web Architecture
- Asynchronous Logging Using Spring
- Java for Programmers (2nd Edition)
- Is Write Once Run Anywhere Ever Going to Be a Reality?
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- JavaServer Faces (JSF) vs Struts
- The i-Technology Right Stuff
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- What's New in Eclipse?
- i-Technology Predictions for 2007: Where's It All Headed?























