HTTP does support output through the POST method as well as GET (that's the
"x?a=1&b=2" style). POST lets you send large amounts of information up to
the web server. To use the POST method from the URL classes, you will need
to obtain a URLConnection (URL.openConnection() as you're doing) but then
invoke the setup method URLConnection.setDoOutput() before trying to write
to the stream.

Check out the Custom Networking tutorial for more information:
http://java.sun.com/docs/books/tutorial/networking/index.html

hth,
Phil

At 11:34 AM 8/2/01 -0700, you wrote:
>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

Reply via email to