public class ServletExample
extends javax.servlet.http.HttpServlet
By chance (oh, really?) the two invoke() methods have the same signature. By registering an XmlRpcClient as an invocation handler, when the server receives a call to that handler, it calls its invoke() method as it does with all handlers. The invoke() method of the client, as I explained, in turn calls the server for which it was created. We have created a kind of relay that is very useful when an applet is performing XML-RPC invocations on the server it was loaded from. Applets may only communicate with the server it originated from, but if that server has registered an XmlRpcClient as an invocation handler, that client will act as a relay to another XML-RPC service.
The sample servlet registers an XmlRpcClient under the name "Speller", which is hooked up to the spelling service at stuffeddog.com. Invoking the "Speller.invoke" method on this servlet, will make the client autmatically relay the call to the stuffeddog server and back to the caller. Fancy stuff. The first argument to the "Speller.invoke" method must be the method name to call at stuffed dog. This is true when calling all clients acting as relays. The second argument is the text to check the spelling for (a string), and the final argument should be a Hashtable containing settings for the spell checker. An empty Hashtable should be used (it does not support settings yet).
This is an extension to a sample servlet posted by David Watson at SourceForge. Thanks!
Modifier and Type | Class and Description |
---|---|
static class |
ServletExample.ExampleInvocationHandler |
Constructor and Description |
---|
ServletExample() |
Modifier and Type | Method and Description |
---|---|
void |
doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
This is your standard handy dandy doPost() as it could appear in any servlet using
an XmlRpcServer.
|
void |
init(javax.servlet.ServletConfig config)
|
public void init(javax.servlet.ServletConfig config)
init
in interface javax.servlet.Servlet
init
in class javax.servlet.GenericServlet
public void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
doPost
in class javax.servlet.http.HttpServlet