Java
  Home arrow Java arrow Using RMI with Apache Jserv
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
JAVA

Using RMI with Apache Jserv
By: Richard Yumul
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 5
    2000-01-21


    Table of Contents:
  • Using RMI with Apache Jserv
  • Design the Remote Interface
  • Create the client program (the servlet)
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Using RMI with Apache Jserv
    ( Page 1 of 4 )

    One of the greatest advantages which Jserv brings to Apache is ability to leverage the large number of API's available to Java. Remote Method Invocation (RMI) delivers several significant benefits to the servlet solution. The primary benefit of using RMI with servlets is that it significantly expands the variety of datasources which Apache can serve to the browser. Furthermore, RMI's simplifies code on the client side of the RMI connection (the servlet), and also allows for load distribution.

    One of the greatest advantages which Jserv brings to Apache is ability to leverage the large number of API's available to Java. Remote Method Invocation (RMI) delivers several significant benefits to the servlet solution. The primary benefit of using RMI with servlets is that it significantly expands the variety of datasources which Apache can serve to the browser. Furthermore, RMI's simplifies code on the client side of the RMI connection (the servlet), and also allows for load distribution.

    For example, if you wanted a servlet to access a database through JDBC, you would start off with importing the java.sql package into your servlet. Then your servlet would have to manage handling the database connection, preparing and executing SQL statements, as well as managing the result sets. This adds a lot of complexity to your servlet, as not only does it have to handle logic & return appropriate responses to the browser, it is also bogged down managing communications with the database.


    Servlet <== JDBC ==> Database
    With RMI, an abstraction layer is added between the data source and the servlet. This layer, the RMI Service (or server tier), provides an simplified interface to the client, handling all of the internals of communicating with the database.

    Servlet <== Remote Interface ==> RMI Service <== JDBC ==> Database
    So, instead of having to manage the database communications in your servlet, RMI hides all the that from your servlet behind its remote interface.

    With RMI, the server tier can be anything, as long as it implements the defined remote interface. The service could even be hosted on a different machine with a different operating system. The client will not care if the server tier stores its data in a database, LDAP server, or even text files. Your Linux Apache-Jserv box could be pulling data from an application server on a Solaris box.

    Example

    Using RMI with Apache Jserv is fairly straight-forward, and the procedure in this example pretty much follows the RMI examples which can be found in the JDK documentation or Sun's tutorial. The steps include:

    1. Design the remote interface
    2. Implement the remote interface
    3. Compile the classes, create the stub and skeleton classes
    4. Create the client program (in this case, the servlet)
    5. Deploy

    In the following example, we will create a simple email address book. The server will store it's data in a Hashtable. Of course, the data in the server will disappear when the server is stopped, but that's okay for this example's purposes. For a more robust server, the address book data could be stored in a database, LDAP server, or any other type of data storage. The servlet (client) will use the address book service through RMI.

    There are three packages in our example. The first one, is the directory.* package. It holds the remote interface class, as well as the Entry class, a data structure representing an directory record. The server package will contain the implementation of the remote interface. The client package contains the servlet which talks to the server implementation via RMI.



     
     
    >>> More Java Articles          >>> More By Richard Yumul
     

       

    JAVA ARTICLES

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek