Ask your own question, for FREE!
Computer Science 11 Online
OpenStudy (woodrow73):

I have a java program that takes input from my website in order to perform certain actions. I hacked this concoction together by having buttons on my website that change data in my mysql database -- from there, my java program is constantly checking the mysql database for data, and responding if there is a change. This hacky solution of using a website to interact with a java program on my desktop work great, but I feel like it isn't very efficient.. and I'm pretty sure it doesn't work over long periods of time (5 hours) - still have to test more. I'd be interested to hear alternatives to accomplish the same thing.. since this topic fascinates me. I'd also prefer it to be event-driven data exchange between my website and my java program, as opposed to the java program querying for updates every couple of seconds. Any input appreciated. -Alex

OpenStudy (rsmith6559):

First, do you understand CGI ( Common Gateway Interface )? That's how to exchange data between the client and the server. Once that's squared away, JavaScript, or a Java applet for the client can handle the user interface.

OpenStudy (woodrow73):

Thanks for the tip, I'll definitely look into it! I might have been unclear - but the java program is literally on my computer alone - it isn't part of the website, or online; a standard desktop application. Besides CGI, I'm also looking into http://socket.io/ as a possible solution.

OpenStudy (anonymous):

The HTTP protocol is not very good with event driven communication. I'm guessing that your Java program has to be the client, and it can't receive incoming requests from the internet. If that is the case, then you'll need the server to start up a server socket, and you'll need your Java program to connect to it with a client socket. A server socket will bind to an address and port and accept sockets that try to connect. A client socket will connect to an address and port of the server socket. Upon connection the sockets will be able to read and write data to each other. The server can write to the socket anytime it wants, so it doesn't have to wait for a request to respond back.

OpenStudy (woodrow73):

Great, thanks wio; sounds spot on for what I'm looking for. I look forward to posting an update when I get more informed, and start playing around with it some more.

OpenStudy (rsmith6559):

Just be careful with the security issues that ANY server socket on the Internet poses.

OpenStudy (woodrow73):

Thanks for the heads up.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!