Ajai,

See the added line of code below.

>
> Hello all !!
> I tried to send an object (hash table ) from an applet to a
> servlet. What i
> did was i opened a URL Connection Object to the Servlet ,got the
> outputstream  and then Serialized the Hastable and wrote it to the Output
> stream .It doesnt give me any errors ..it simply hangs during the run . If
> some one could help me it would be great ...
> Here is the code :
> I am Calling this execute() method in the init() method of my applet.
>
>   public void execute()
>   {
>
>   hash =new Hashtable();
>   hash.put("firstname","ajai");
>   hash.put("lastname","kumar");
>   taResults.setText(hash.get("firstname").toString()+"
> "+hash.get("lastname").toString());
>   try{
>       url=new URL("http://localhost:8080/servlet/HashServlet1");
>       uc=url.openConnection();
>       uc.setDoOutput(true);
>       uc.setDoInput(true);
>       uc.setUseCaches(false);
>       uc.setRequestProperty("Content-type","application/octet-stream");
>       OutputStream out=uc.getOutputStream();
>       ObjectOutputStream outstream=new
> ObjectOutputStream(uc.getOutputStream());
>       outstream.writeObject(hash);
>       outstream.flush();
>       outstream.close();

        uc.connect();  // <<<<<< add this <<<<<<<<<<<<<<<<<<<<<<<<<

>
>      // out.close();
>
>       taResults.append("Object Sent");
>
>
>       InputStreamReader in=new InputStreamReader(uc.getInputStream());
>       StringBuffer buf=new StringBuffer();
>       int chr=in.read();
>       while( chr!=-1){
>       buf.append(String.valueOf((char)chr));
>       System.out.print(String.valueOf((char)chr));
>       chr=in.read();
>       }
>       in.close();
>       taResults.append(buf.toString());//taResults is a text area  i am
> appending what i read back from the servlet.
>   }
>   catch(Exception ex){
>   ex.printStackTrace();
>   }
>   }
>
> Thanks everyone :-)
>


Rob Griffin
Quest Software

E-mail: [EMAIL PROTECTED]
Web site: http://www.quest.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