• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 473
  • Last Modified:

Java RMI

Does anyone know the disadvantages of Java RMI? Thanks in advance!!!
0
beneflex
Asked:
beneflex
  • 2
  • 2
1 Solution
 
JodCommented:
Advantages of RMI are many, but the main disadvantages are:

RMI is a Java only communication protocol - it is not a general communications standard that can be interfaced to and used from any language. You have to be using Java to use RMI to transport your data and objects (unlike CORBA for example, which is designed to be interfaced to and used from any programming language).

It also does not provide a fully featured protocol for communicating between all registered processes - you can only invoke the methods declared in the interface you specify - so there is no real time communication between the client and the server (such as general messageing or event handling).

This leaves RMI as a very spartan interface to use in it's basic form as it does it's job well, but really you need to extend it's functionality to make it more genuinely useful for general applications.
0
 
beneflexAuthor Commented:
Thanks Jod!
0
 
mbormannCommented:
Jod,
I read Jason Hunter's excellent book on Servlets where he talks abt Servlets and RMI ,what is the use of having them both?

I mean servlet acts as a Client or sometimes as a Server?Pls expalin?

Thanks
Amit
0
 
JodCommented:
To quote:

What an applet is to a browser, a servlet is to a server. In simple terms, servlets are Java programs that are executed inside a server, usually, but not necessarily, a web server. Servlets can do anything a cgi script can do and usually faster, since cgi-script start-up overhead is avoided, and the Java intrerpreter is embedded in the web-server.

Servlets are an extension to your Web Server to create dynamic html that can display web pages that change based on data in a database or the current user or the time or whatever.

When you request a page from a web server then if that page is partly or totally created by a servlet then the web server will load the servlet and using http requests will return a page or data within a page to the client browser.

For example, a servlet could be used to create a shopping basket application that tracked the current user and showed the details of items they may want to purchase on your site by displaying these in the web page.

Previously, this would be done with CGI programs which are generally not portable, can be slow and often don't provide many advanced features for web pages.

However, Servlets are not limited to this and have full access to all the Java API so Jason Hunters book provides examples of how to extend servlets to use RMI to communicate with applets in order to provide more features and a greater level of communication with the client browser.

The link below has lots of info to help clarify things.

http://www.cs.odu.edu/~cs745/presentations/servlet/

A simple servlet looks like this:


import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;


/**
 * This is a simple example of an HTTP Servlet.  It responds to the GET
 * and HEAD methods of the HTTP protocol.
 */
public class SimpleServlet extends HttpServlet {

    public void doGet (HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException
    {
        ServletOutputStream out = res.getOutputStream();

      // set content type and other response header fields first
        res.setContentType("text/html");

      // then write the data of the response
        out.println("<HEAD><TITLE> SimpleServlet Output </TITLE></HEAD><BODY>");
      out.println("<h1> SimpleServlet Output </h1>");
      out.println("<P>This is output from SimpleServlet.");
      out.println("</BODY>");
      out.close();
    }

    public String getServletInfo() {
        return "A simple servlet";
    }
}

It responds to certain methods of the HTTP protocol that could be invoked by the browser when you open a page. In this case, it dynamically creates a page and displays it by passing the html text out through the HttpServletResponse outputstream which is passed into the doGet method.

Servlets can also be extended to do things when buttons are pressed on html forms or to be embedded in parts of an existing html page.

However there are a limited number of ways to communicate with a servlet over HTTP, so using RMI will allow you to invoke various methods in the servlet
that could provide more advanced functions.

Also it is easier to write and use Servlets than develop standalone Applications which run on the server, so you can use RMI to communicate with the servlet which can then have (nearly) all the functionality of a server based application which communicates with your Applet.

The only limitation is that servlets have no user interface of their own, but this is not really a problem with server side services.
0
 
mbormannCommented:
Thanx ,will read it and let u know.
:-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now