This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Servlet-applet communcation  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Task - to send unknown number of objects in unknown period of time from server to client (applet)
What are possible ways to implement this task?
I tried 2 approaches, both failed to work:
1) Applet using URLConnection makes request to the servlet. Servlet obtains OutputStream and passes it to the class which will later send objects through the client.
Doesn't work, as output stream seems to be closed after servlet doGet() method returns
2) Applet creates ServerSocket which listens for incoming requests on specified port. Then applet makes request to the servlet. Servlet obtains remote hostname and passes it to the class. This class creates socket and sends object through it when when such necessity arises
Doesn't work as ServerSocket cannot be instantiated (constructor throws exception)
Please let me know if better approach exists or if my approaches are correct or not
Thank you
 
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simplest thing would be to have the applet contact the servlet and retrieve one or more objects in a single request-response cycle. To determine if any new data is available you might be able to do a HEAD request first and have the servlet return a date-last-modified header that would indicate when new objects were available and should be downloade.
I imagine the attempt to open a ServerSocket on the applet side ran into a security exception since opening arbitrary sockets on the client side is a security risk. You might be able to do this if you signed the applet.
Bill
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!