try this
bufferedReaderIn = new BufferedReader(new
InputStreamReader(inputStreamResult))

=>JDK 1.2




sandor/28:48

Veuillez r�pondre � "A mailing list for discussion about Sun Microsystem's
      Java              Servlet API Technology."
      <[EMAIL PROTECTED]>

Pour :    [EMAIL PROTECTED]
cc :   (ccc : Bertrand MASTALERZ/FRANCE/NORSYSF)
Objet :   ClassCastException in appl-serv communication




Hi, I am having a problem with my applet-servlet communication.

I've made a class that I use to communicate from an applet to the
servlet. At first I had this code in a try block:

                host = parentApplet.getDocumentBase().getHost();
                port = parentApplet.getDocumentBase().getPort();
                if (port != -1) host += ":" + port;
                URL servletURL = new URL("http://" + host + "/servlet/"
+ servletToConnectTo);
                URLConnection uc = servletURL.openConnection();
                uc.setDoOutput(true);
                uc.setDoInput(true);
                uc.setUseCaches(false);
                uc.setDefaultUseCaches(false);

uc.setRequestProperty("Content-type","application/octet-stream");

               objOut = new ObjectOutputStream(uc.getOutputStream());
               objOut.writeObject(vectorToSend);

               objOut.flush();
               objOut.close();

               ObjectInputStream objIn = new
ObjectInputStream(uc.getInputStream());
               stringFromServlet = (String)objIn.readObject();
               objIn.close();

This gave me IOException and "An Error ocrred while Netscape was
receiving data (connection reset by peer)".
Then I searched the archives and changed this line of code:

               objIn = new ObjectInputStream  ((BufferedInputStream)
uc.getInputStream());

This seemed  to get rid of the previous error, but it gave me a new one.
ClassCastException.

Then I searched the archives again and someone sugessted to remove
servlets from the servlets directory and put them in the system's
classpath. How do I invoke the servlet via URL if it's not in the
servlets directory?

I tried making a new directory under JWS (eg myServlet), but this didn't
work.
URL servletURL = new URL("http://" + host + "/myServlet/" +
servletToConnectTo);

Any ideas on how to fix this problem.

Thanks

Robert

___________________________________________________________________________
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

___________________________________________________________________________
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