Hi,
I am trying to send a serialised object to a servlet. The problem is I cannot
seem to connect to the servlet at all. Here are the main code snippets:
>From Applet:
public void sendSerlisedObject()
{
try
{
URL servletURL = new URL("http://s_webdev2/servlet/EmailServlet");
URLConnection servletConnection = servletURL.openConnection();
ObjectOutputStream outputToServlet;
/* Inform the connection that we will send output and receive input */
servletConnection.setDoOutput(true);
servletConnection.setDoInput(true);
/* Don't use a cached version of URL Connection */
servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches(false);
/* Set the content that we will be sending binary data */
//servletConnection.setRequestProperty("Content-Type",
"application/java-serialized-object");
servletConnection.setRequestProperty("Content-Type","application/octet-stream");
/* Convert OutputStream to ObjectOutputStream */
outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream());
/* Serialise the object */
outputToServlet.writeObject(emailSerialisedObject);
/* Actually send the object now */
outputToServlet.flush();
outputToServlet.close();
}
where emailSerialisedObject is an object which implements Serializable
Servlet Code:
public synchronized void doPost(HttpServletRequest req, HttpServletResponse res)
{
try
{
ObjectInputStream inputFromApplet = new ObjectInputStream(req.getInputStream());
EmailSerialisedObject emailObject = (EmailSerialisedObject)
inputFromApplet.readObject();
inputFromApplet.close();
}
catch(Exception e)
{
log("Error from servlet was " + e.getMessage());
}
}
NOTES:
Using JRun 2.3 / Netsvape Server 3.6
any help/suggestions would be greatly appreciated.
regards.
gerardo
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html