Example 2: Servlet using RMI to call into the TradingSystemImpl class.

TradingSystemInterface tradingSystem;
try {
  Registry rmiRegistry = LocateRegistry.getRegistry();
  tradingSystem = (TradingSystemInterface)
      rmiRegistry.lookup("TradingSystem");
} 
catch ( Exception e ) { 
}
 ...
// buy 10 shares of IBM stock
tradingSystem.Buy("IBM", 10); 

// add the new holding to the portfolio
tradingSystem.AddHolding("IBM", 10);