I'm still having trouble with communication between an
Applet and a Servlet on a web-Server. I'm trying to
serialize objects and send them from the applet to
the servlet. Here's the essential code for what I'm
trying to do.
String path = "http://www22.addr.com/~mgardne/servlets/UserServlet";
URL servletURL = new URL(path);
OutputStream stream = servletURL.openConnection().getOutputStream();
ObjectOutputStream writer = new ObjectOutputStream(stream);
writer.writeObject(new Integer(UserManager.GET));
writer.writeObject(ID.getText());
writer.writeObject(passWord.getText());
//The servlet should respond with a validation code and a User object
ObjectInputStream reader = new ObjectInputStream(servletURL.openStream());
int result = ((Integer) reader.readObject()).intValue();
User user = (User)reader.readObject();
The problem is that when I run this code, I get an exception stating
that
" the protocol doesn't support output"
which makes sense since the http Protocol is not designed to accept input from
the client, only to output stuff to the client. I know I could use an
httpServlet and read parameters from the URL
(Something like path = "servletPath?ID = " + ID + "&password=" + password),
but I would like to be able to send some larger objects later on which I
can't really send as normal text.
--If I have two Objects called ID and Password, how do I send them from the
applet to the servlet?
--Monte Glenn Gardner
___________________________________________________________________________
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