- From: S.Ramaswamy <srswamy@giasdl01.vsnl.net.in>
- Date: Mon, 7 Dec 1998 23:01:24 -0500 (EST)
- To: bhagya@isac.ernet.in
- CC: www-jigsaw@w3.org, world@mech.iitkgp.ernet.in, sudhin@KONARK.NCST.ernet.in
- Message-ID: <366CA035.F8824FD5@del1.vsnl.net.in>
bhagya@isac.ernet.in wrote: > >From bhagya@isac.ernet.in Wed Dec 2 17:34:55 1998 > Date: Wed, 2 Dec 1998 17:34:53 +0000 (GMT) > From: <bhagya@isac.ernet.in> > X-Sender: bhagya@ws05 > To: gajit@xetex.com > Message-ID: <Pine.A41.3.96.981202172700.17198A-100000@ws05> > MIME-Version: 1.0 > Content-Type: TEXT/PLAIN; charset=US-ASCII > Status: RO > X-Status: > > hi, > > I'm using > > Netscape Communicator 4.06 > Servlet JSDK2.0 jsdk.jar > JDK1.1.2 > > I need to load an applet from HTML page (in the browser), which in > turn need to invoke a servlet and pass data between applet and servlet. > can u please help me with this. > > -bhagya > > p.s : i could do this outside the browser. meaning, i could call the > applet from main and do the rest without any problem. but when i load the > applet from HTML page in a browser, it doesn't work. ----------------------------------------------------------- 1. Applet invoking servlet with url supplied --------------------------------------- void putObject(Serializable obj, URL url) { try { URLConnection uc = url.openConnection(); uc.setDoOutput(true); uc.setUseCaches(false); uc.setDefaultUseCaches(false); uc.setRequestProperty("Content-type","application/octet-stream"); ObjectOutputStream objOut = new ObjectOutputStream(newGZIPOutputStream(uc.getOutputStream())); objOut.writeObject(obj); objOut.flush(); objOut.close(); InputStream is = uc.getInputStream(); } catch (IOException e) { System.out.println("Exception putting object " + e.toString()); } } ----------------------------------------------------------- 2. Servlet processing the response -------------------------------- public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ................. response.setContentType("application/octet-stream"); ObjectOutputStream objOut = new ObjectOutputStream(response.getOutputStream()); objOut.writeObject(someVectorObject); objOut.flush(); objOut.close(); } ----------------------------------------------------------- 3. Applet receiving from servlet ----------------------------- private Object getObject(URL url) { ObjectInputStream objIn = null; Object obj = null; try { objIn = new ObjectInputStream(new GZIPInputStream(url.openStream())); obj = objIn.readObject(); } catch (ClassNotFoundException e) { System.out.println("Exception creating URL " + e.toString()); } catch (IOException e) { System.out.println("Exception getting object " + e.toString()); } finally { try { objIn.close(); } catch (IOException e) { System.out.println("Unable to close stream " + e.toString()); } } return obj; } ___________________________________________________________________________ S.Ramaswamy Matrix Infotech Syndicate D-7, Poorti, Vikaspuri, New Delhi, 110018, India PHONE: +91-11-5610050, FAX: +91-11-5535103 WEB : http://MatrixInfotech.HyperMart.Net
Received on Tuesday, 8 December 1998 04:56:00 UTC