• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

send socket from applet to servlet

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
I have an applet which creates a socket to a server . I want to be able to send this socket to a servlet. I am sending a string from the applet to the servlet (using writeObject) but that doesn't work for sending the socket . I keep getting a "not serializable" error. I set the requestProperty as follows:
servletConnection2.setRequestProperty("Content-Type","application/octet-stream");

How can I send a socket from applet to a servlet.
thanks in advance.
G.
[ January 06, 2005: Message edited by: Gauri Deshmukh ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can't be done. The simple answer is that java.net.Socket does not implement java.io.Serializable and therefore cannot be serialized (see the . Java Tutorial: Object Serialization for more about that).
The more in-depth answer is that a socket is not a resource like a file which can be read in and transmitted. It is an operating system abstraction of a very real, physical thing: the network cable plugged into the back of your computer. What you are trying to do is like trying to stuff one end of your network cable in an envelope and mail it to a friend. It won't get far!
 
Gauri Deshmukh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Joe,

I have another question, can I send the port number (for the local socket) from the applet to servlet and retrieve the actual socket on the servlet side?
Let me know.
Thanks,
G.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bind to a local port in the applet and send the port number to the server like you were above? I don't see any problem.
 
I've never won anything before. Not even a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic