Hi All,
I need to do Applet-Servlet Communication. I'm able to communication from
Applet to Servlet but not vice-versa. While I try to get results from
Servlet it gives following exception:
java.io.StreamCorruptedException: InputStream does not contain a serialized
object
I'm working with JDK1.1.8 on NT4.0. My appletside code is :
URLConnection con = servlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
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();
ObjectInputStream in=new ObjectInputStream(
con.getInputStream());
And my Servlet code is:
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
ObjectInputStream in = new ObjectInputStream(req.getInputStream());
ObjectOutputStream out = new
ObjectOutputStream(resp.getOutputStream());
try {
String data1 = (String)in.readObject();
String data2 = (String)in.readObject();
String result = db.Login(data1,data2);
Serializable objs1[] = {result};
out.writeObject(objs1[0]);
out.flush();
out.close();
in.close();
} catch (Exception e) {
System.out.println("Exception in UserLogin Servlet: "+e);
}
}
Please let me know, where am I wrong ?
Thanks & Regards,
Sandeep.
___________________________________________________________________________
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