• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How To Connect a Servlet with an Applet

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please tell me how to connect an applet to a servlet ?
Give a small piece of code and some other documentation
available on the net .
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi vijay
u need to write following lines in ur Servlet...
ObjectOutputStream ToApplet=new ObjectOutputStream(response.getOutputStream());
ToApplet.writeObject("name of the obj to be written to applet");
ToApplet.flush();
ToApplet.close();
u need to write following lines in ur Applet...
String servletLocation ="http://localhost:8080/servlet/nameofurservlet;
URL empDBservlet = new URL( servletLocation);
URLConnection servletConnection = empDBservlet.openConnection();
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches(false);

ObjectInputStream FromServlet = new ObjectInputStream(servletConnection.getInputStream());
//read the values from the input stream....
gnames = (String) FromServlet.readObject();
------------------------
in gnames u will get the values written by servlet

i think this will solve ur problem
best luck
Ajit

 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic