Hello,
I am using the following code in servlet's get method

res.setContentType("application/octet-stream");
        ObjectOutputStream outputToApplet = new
ObjectOutputStream(res.getOutputStream());

outputToApplet.writeObject(mainHT);
outputToApplet.flush();
//outputToApplet.close();



In the APPLET I am using the following code:



try
    {
      String urlString = getDocumentBase().toString();

      urlString = urlString.substring(0, urlString.lastIndexOf("/")+1)+
                                          "servlet/"+servletName;

      URL servletURL = new URL(urlString);

      URLConnection servletConnection = servletURL.openConnection();

      servletConnection.setDoInput(true);
      servletConnection.setDoOutput(false);
      servletConnection.setUseCaches(false);
      servletConnection.setRequestProperty("Content-Type",
"application/octet-stream");

      ObjectInputStream inputStmFromServlet =
            new ObjectInputStream(servletConnection.getInputStream());

      Object receivedObj = inputStmFromServlet.readObject();
      inputStmFromServlet.close();
      return receivedObj;

Hope this will give more insight to the problem.

Thanks
S


>From: Danny Rubis <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
>        Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: IOException in Applet-Servlet Communication
>Date: Mon, 18 Dec 2000 19:10:08 -0500
>
>Hey!
>
>Send the list a small sniplette of you code where you are
>doing the IO.  How can we tell otherwise?
>
>Sans adieu,
>Danny Rubis
>
>puppala sreenivas wrote:
>
> > Hello All,
> >
> > I am having the applet-servlet communication in my project and in the
> > initial testing it self I am getting this exception in Netscape's java
> > console
> >
> > java.io.IOException: The document contained no data.
> > Try again later, or contact the server's administrator.
> >
> >   at netscape.net.URLConnection.connect(Compiled Code)
> >
> > * at netscape.net.URLConnection.getInputStream(Compiled Code)
> >
> >   at CheckListApp.receiveObject(Compiled Code)
> >
> >   at CheckListApp.loadInitialData(Compiled Code)
> >
> >   at CheckListApp.jbInit(Compiled Code)
> >
> >   at CheckListApp.init(Compiled Code)
> >
> >   at
>netscape.applet.DerivedAppletFrame$InitAppletEvent.dispatch(Compiled
> > Code)
> >
> >   at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled
>Code)
> >
> >   at java.awt.EventDispatchThread.run(Compiled Code)
> >
> >   at
> >
>netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled
> > Code)
> >
> > Can anybody giude me on this? I am able to see the hello world servlet
>in
> > the servlets directory of my web server.Here it self is my servlet's
>class
> > file.
> > TIA
> > S
> >
>_________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at
>http://www.hotmail.com.
> >
> >
>___________________________________________________________________________
> > 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

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

___________________________________________________________________________
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