GeeCON Prague 2014*
The moose likes Sockets and Internet Protocols and the fly likes Sending data from Web Application to a Desktop Java Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Sending data from Web Application to a Desktop Java Application" Watch "Sending data from Web Application to a Desktop Java Application" New topic
Author

Sending data from Web Application to a Desktop Java Application

Hardik Raja
Ranch Hand

Joined: Feb 07, 2006
Posts: 117
hello javaranchers,

I have a Web application and a Desktop java application running on two different systems. My requirement is as follows :

The Web application need to establish a communication with the desktop java application and send some data to it. I am not quite sure which technology to use to carry out the above process.

Could anyone please share their thoughts on the technology/process that could be used to do this.
Thanks in advance.

Regards,
Hardik
SCJP
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
Sockets are probably the easiest way. But the all-important question is: how does the web app know on which IP address the desktop app runs?


Ping & DNS - my free Android networking tools app
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Another thought would be to write a desktop app hat polls the servlet app every n minutes or seconds. If it only need to check hourly or daily, you could use a cron job or a Windows Scheduler job to invoke the Java app, rather than have it run as a service.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Hardik Raja
Ranch Hand

Joined: Feb 07, 2006
Posts: 117
Another thought would be to write a desktop app that polls the servlet app every n minutes or seconds.


Could you explain in bit detail how can a desktop app poll servlet app ?
Hardik Raja
Ranch Hand

Joined: Feb 07, 2006
Posts: 117
Sockets are probably the easiest way. But the all-important question is: how does the web app know on which IP address the desktop app runs?


Ya thats true, I was also wondering how to accomplish this ? Any other idea ?

Below are my thoughts on your comment, please correct me if I am wrong

Socket programming helps us achive client - server communication in which server would be waiting for clients to connect to them and communicate with them.

But here I require peer - peer communication (Web application to java desktop application) in which web application upon recieving some data would be creating connection and sending that data to java dektop application.

Thanks
Hardik
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8914
    
    8

Could you explain in bit detail how can a desktop app poll servlet app ?

You simply make a request to the servlet at a certain interval. Are you unfamiliar with timers in Java or how to talk to a servlet?

Socket programming helps us achive client - server. . .
But here I require peer - peer communication


You are drawing a distinction where none exists. It is not uncommon to have network peers communicate using sockets. Contacting a servlet via URL uses sockets. The difference between the two is the protocol.
You need to take a look at your requirements. Does your desktop app need instant updates from the web app? Polling will not do. Updates every few minutes? Polling may make sense. If you need the web app to send instant updates, as Ulf indicated, your web app will need to know how to contact it. It can do so directly (the desktop app listens on a socket and the web app contacts it via custom protocol) or you use some intermediary like Java Message Service to handle the details of transmission.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Hardik Raja
Ranch Hand

Joined: Feb 07, 2006
Posts: 117
Dear Joe,

Many thanks for your reply.
Are you unfamiliar with timers in Java or how to talk to a servlet?


Could you please give some brief idea about this ?

Kind regards,
Hardik Raja
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending data from Web Application to a Desktop Java Application