aspose file tools*
The moose likes Applets and the fly likes Sending data to an applet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Sending data to an applet." Watch "Sending data to an applet." New topic
Author

Sending data to an applet.

Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 90
Sending data to an applet.

I know that an unsigned Java applet can only make a socket connection to a socket server on the same host as the web server (from which its hosting web page was downloaded).

I need my Java applet to be able to receive data from a remote server. So my idea is to run a socket server on the web server which the Java applet will connect to and then the Java applet can poll for data. Is this the only way? Any ideas would be welcome?

Another idea I thought about was to have a proxy on the web server redirect data on a particular port (the port used by the remote server) from the web server host to the host where the server resides. Is this possible?

How do others do this type of thing?

Or am I best to sign my applet? But if I sign my applet does each client have to 'allow' the applet to run? I need it to be easy for clients.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Signing means that the client will be presented with the certificate in a dialog, prompting him to accept or deny. So, yes, the client needs to allow it. How scary that dialog looks depends on how trusted the certificate is - signing by "Angus Comber" will result in a dialog looking less wholesome than signing by Thawte or Verisign :-)

Running a proxy on your web server is a common approach, though, assuming you don't expect thousands of users, or your web server's connectivity sucks, or its connectivity to the target machine sucks.
Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 90
I am interested in the proxy use. But if the socket communication is to be proxied does that mean that the protocol would have to be HTTP? Is it generally only http traffic that can be proxied?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
No, you could straight TCP/IP as well, or some other protocol. HTTP is just convenient because port 80 is probably open already (it would have to be to serve the applet). As long as you can get your sys admin to open some other port, you can use whatever protocol you wish on that port.
Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 90
Are you talking about standard off-she-shelf proxies? I am thinking my customer could use something standard, eg Microsoft proxy if a Windows server - but how would it know where to send the data to? Do you configure an ultimate remote destination for each port?

Eg my real remote server, realserv, listens on port 5000. I then get the proxy to redirect to realserv:5000 ? Is that all you need to do?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

You're asking about port forwarding, it seems. In that case yes, when you configure port forwarding for a port, you do have to configure where the requests get forwarded to. Would be kind of pointless without that information, wouldn't it?
Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 90
I don't like your attitude. I, like many people, asked a question because I am unsure or don't know the answer. Sarcastic comments are really not helpful.

While it sounds logical that you would configure port forwarding on a proxy in this way, I did not know because I have no experience configuring proxies. If I did I wouldn't have asked the question. So thank you for the information but you should seriously think about your arrogant attitude.

Paul Clapham wrote:You're asking about port forwarding, it seems. In that case yes, when you configure port forwarding for a port, you do have to configure where the requests get forwarded to. Would be kind of pointless without that information, wouldn't it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending data to an applet.