I'm having an Applet oppening a URLConnection with a servlet and sending
an object.
Here's the Applet side of the communication:
//This is the method initiating the connection
public void available(SellOrder o) throws Exception
{
URL servlet = new URL("http", "localhost", 8080,
"/servlet/AvailableServlet");
Serializable objs[] = { o };
ObjectInputStream in = ServletWriter.postObjects(servlet,
objs);
String status = (String) in.readObject();
in.close();
}
----
public class ServletWriter {
static public ObjectInputStream postObjects(URL servlet,
Serializable objs[]) throws Exception
{
URLConnection con = servlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setDefaultUseCaches(false);
con.setUseCaches(false);
con.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
// Write the arguments as post data
ObjectOutputStream out = new
ObjectOutputStream(con.getOutputStream());
int numObjects = objs.length;
for (int x = 0; x < numObjects; x++) {
out.writeObject(objs[x]);
}
out.flush();
out.close();
return new ObjectInputStream(
con.getInputStream() );
}
}
On the server side of the communication I have the AvailableServlet with
the following code:
public class AvailableServlet extends HostServlet {
public void doPost(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
System.out.println("Available is called.");
ObjectInputStream in=
new
ObjectInputStream(req.getInputStream());
ObjectOutputStream out=
new
ObjectOutputStream(res.getOutputStream());
try {
//read the host order
SellOrder o = (SellOrder)
in.readObject();
_server.available(o);
out.writeObject("OK");
in.close();
out.close();
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
}
This communication works fine when running with Tomcat 3.2.1 (Windows XP
Pro - standalone). But it throws the following exception on the server
when running on Tomcat 4.0.3 (same platform standalone or service):
----
Available is called.
RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments;
nested excep
tion is:
java.net.MalformedURLException: no protocol: Files/Apache
----
As you can see from the output the doPost() method is called. The
exception is thrown when the doPost() method executes the readObject()
method on the stream.
Any help would be greately appreciated.
Thanks
-George