Образец RMI
public interface Account
extends java.rmi.Remote {
public double balance(int accountNumber)
throws java.rmi.RemoteException;
}
public class AccountImpl
extends
java.rmi.server.UnicastRemoteObject
implements Account {
public AccountImpl()
throws java.rmi.RemoteException {
super();
}
public double add(int accountNumber)
throws java.rmi.RemoteException {
return 1000.0;
}
}
Образец сервлета
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
Account service=request.getSession()!=null ?(Account)request.getSession().getAttribute(loginService.ACCOUNT_SERVICE.name()):null;
service=service!=null?service:getService();
if(service!=null)
{
request.getSession().setAttribute(loginService.ACCOUNT_SERVICE.name(), service);
}
}
}
}