Chapter 12

Servlets and RMI

 

 

Universal TeacherServlets are Java classes that are loaded and executed by a web server. This chapter shows an example in which a servlet invokes remote methods.

The source code needed for this example is stored in the examples\ServletsandRmi directory. The "ServletsandRmi" directory contains the following files:

  • ServerHandlerInterface.java
  • ServerHandlerImpl.java
  • ClientServlet.java
  • Client.html
  • Compile.bat
  • Rmicompile.bat
  • RunServer.bat

To run this example you need the following:

A web browser
Java Web Server


The Server Interface

The ServerHandlerInterface defines a method that takes a string object (name of the user) as its argument and returns a small message.

Listing 12.1 ServerHandlerInterface.java


import java.rmi.*;

//server interface
public interface ServerHandlerInterface 
	extends Remote{
	
	//This method gets the name of the user.
	public String servletTest(String name)
		 throws RemoteException;
}
 

 

RMI BOOK MAIN PAGE                Top

  
Copyright © 2001 www.universalteacher.com