An example of using ServletInvokerApplet.

ENTERPRISE JAVA
Invoke Servlet Methods From Java Apps

David Tayouri
Listing 2. An example of using ServletInvokerApplet.


public class MyApplet
    extends ServletInvokerApplet
{
    . . .
    servletUrl = new URL("http://" + host +":"+
      port + "/servlet/AServlet");
    . . .
    //=========================================
    private void handleEvent(long itemId)
    {
        Vector params = new Vector(1);
        params.addElement(
            new Long(itemId));
        Object obj = invokeServletMethod(
            "sendEvent",
            params);
        if (obj == null) {    // Successful rc
            // Show a success message
        } else if (obj instanceof 
            EventHandlingException) {
            // Show an event handling error msg
        } else {
            // Show a general error message
        }
    }
}