puppala sreenivas wrote:

> Hi,
> Here is my code snippet:
>
> Servlet:
>
> public void doGet(HttpServletRequest req, HttpServletResponse res) throws
> ServletException, IOException{
>
>    Hashtable mainHT = new Hashtable();
>    mainHT = processSelect();
>
>    res.setContentType("application/octet-stream");
>   ObjectOutputStream outputToApplet = new
>   ObjectOutputStream(res.getOutputStream());
>
>   outputToApplet.writeObject(mainHT);
>   outputToApplet.flush();
>   //outputToApplet.close();
> }
>
> Applet:
>
> public Object receiveObject(String servletName)
> {
>    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;
>    }
>    catch(IOException ioe)
>    {
>     System.out.println("Exception ioe");
>     System.out.println(ioe);
>     ioe.printStackTrace();
>     return null;
>    }
>    catch(Exception e)
>    {
>      e.printStackTrace();
>      return null;
>    }
>
> }
>
> Hope with this some one can throw some light on the problem.
> I am having all the class files of applet in the public_html directory and
> servlet's class file is in servlets directory of the web server.
>
> TIA
> S
> [...]

Hi:-)   I run your code with Application-Servlet, and it works. I just
suggest you to notice the following:

    *  I think "Content-  Type" is a *runtime typing-error :-)*,  it should be
        "Content-Type",  otherwise we will get a *invalid header format*
        error:-)

    *   did you put non-Serializable Object into Hashtable? perhaps we
         can not do it, even Hashtable implements java.io.Serializable by
itself.
         for example, when I use the following in Servlet class for testing:
         ...
         mainHT.put(new Object(), new Object());
         ...

         I wil get java.io.NotSerializableException in both Servlet-side and
         Application-side.


Happy new year in advance! :-)
Bo
Dec.20, 2000

___________________________________________________________________________
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