• Post Reply Bookmark Topic Watch Topic
  • New Topic

Web and Desktop application interaction  RSS feed

 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ppl,

I am new to web technology, so please excuse me if I ask any silly questions. I have a project requirement, where I need a desktop java application to interact with web pages. I am currently working in java, so I decided to go with jsp and other java related web technologies. The project requirement is that, there is desktop java application and I need it to interact with web pages. I know that this can be achieved with servlets but as I am new, I need advice from people like you on other ways to achieve this. I have zero idea about jsp, jsf etc. Is it possible to make my desktop app to interact with jsp or should I proceed with servlets. If I need to go with servlets, can the front end be designed as an attractive page? :confused:
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSPs and servlets are conceptually similar as far as interaction with the client goes, so that's not a differentiating criterion.

But the more important question is: what, exactly, do you mean by "interaction"? The best API for Java client code to access web sites programmatically is HtmlUnit, IMO. But if you're in control of both the client and the server code, maybe the best approach is to add a REST API to the web app for the desktop app to use? But this is all speculation until we know what "interaction" means to you.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,
Thanks for the reply. Sorry if I confused you with the word interaction. I will explain it to you with simple example. Lets say a person access my servlet which is designed with lot of buttons. On a specific button click, it should send a command to the desktop application. On receiving a command, the desktop app will have some information, say for example the architecture of the system or OS of the system, etc. The desktop app will now send this information back to servlet and it will be displayed in the browser. This is my requirement but my front end needs to be very attractive, so I think web designers wiil be using css, java script etc.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the desktop user would have both your web app open in a browser, and your desktop app running as well? Or would the web app be operated by someone else -like an administrator- and would contact ALL known running desktop apps? Or just one in particular?

It's not possible for a web app to access a desktop machine directly except in strictly controlled environment, like inside a company network - would that be the case here?
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

Ya. This works in a similar manner which you have said. It is like an company network. An admin will have the web app which connects to all the desktop app in each system. I have control over both desktop app and web app because I am developing both. Sorry I forgot to mention this in earlier post.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The desktop app could register its IP address with the web app when it starts up (and unregister when it's being closed), so the web app would always on which IPs the desktop app runs. These might be REST calls. Then the web app can make a socket connection to some specific port on that IP address (on which the desktop app is listening), and both sides can exchange whatever information they need to according to some predefined protocol.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

I tried making socket connections from servlets but I couldn't. I ended up using servlet streams. Can you give me few examples to learn from this? I need some clarity on REST API too. Please give some examples on that too.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried making socket connections from servlets but I couldn't.

It's certainly possible to do so, but "I tried" and "I couldn't" give us nothing to work with in order to help you.

I ended up using servlet streams.

Those would be used for incoming HTTP streams in the web app. I don't see how they would help when the web app makes an outbound connection.

I need some clarity on REST API too.

The WebServicesFaq has lots of starting points. If you want to get your hands dirty with code, search for "jax-rs tutorial" or "jersey tutorial" - JAX-RS is the standard Java API for REST, and Jersey is the reference implementation.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

I used Seversocket in servlet file and uploaded it in container and tried to connect to it. There was no exceptions, error or connection. So I used request and response for transferring data.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused. Aside from why a servlet container would open a ServerSocket (it already does that for HTTP), this would facilitate client-to-server connectivity - but I understood the point to be server-to-client connectivity. What, exactly, are you trying to do now? It sounds different from what you first described.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

Don't be confused. Consider my web page as Server and the system to connect as client. The client continuously sends some data to Server. In such situation, I need the server to be a web page and the client to be a jar.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I *am* confused, and getting more so. Initially you talked about the web app contacting the desktop app, and receiving some information in response. Now you're talking about the desktop app contacting the web app; actually you said "web page" - does that mean the desktop app has a built-in web page renderer? Or do you really mean that the desktop app accesses some API that just happens to run as part of the web app? None of this is a problem, you just need to decide at some point what the exact flow of communication is.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

I am totally new to web technology. That is why there is some misunderstanding. What I want is a communication flow between a desktop app and a web page. If my admin goes to a certain page say www.mycompany.com/myapp and logs in as admin he should be able to see the information from the system where my desktop app is located. The desktop app will be installed in different machines.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand. But can the admin initiate communication to the desktop app to ask for information, like you said initially? Or does the web app simply show information that the desktop apps sent to the server at some point in time before that? That makes a big difference.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

Admin initiates the process. If he opens the web page, all the systems should connect automatically and on click of a button, say system info button, the system information of the particular system should be displayed.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, then what I said in my 3rd post is valid.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

If you are referring to socket connections, may I know how to do it? Can you give me a small example. Will it be in servlets or jsp?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can learn about sockets in http://docs.oracle.com/javase/tutorial/networking/sockets/index.html. That would be in Java code, so not in JSPs (which contain no code).
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

I know socket programming but I want the interaction to be desktop app to web page.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be precise in stating requirements - the desktop app would not interact with any "web page", it would be contacted by the web app if an admin clicks a button on a web page, correct? If so, what would happen would be socket communication. If you already know that, I'm not sure what exactly you're asking about. Can you be more specific about that? In particular, the flow of events at a detailed level, because I'm getting the impression that you're still not clear on that.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

Process 1: When the admin logs in, all the systems in which my desktop app is running it should connect to it.

Process 2: When the admin clicks on say system information button, the system information should be fetched from there and shown here.

This is my requirement.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Process 1: When the admin logs in, all the systems in which my desktop app is running it should connect to it.

There is no way for the desktop apps to know when someone logs into a web app. But the web app is always running - why wouldn't the desktop apps register with it as soon as they're launched?

Process 2: When the admin clicks on say system information button, the system information should be fetched from there and shown here.

What is "the system information"? Is it different in kind every time the admin clicks that button? If it isn't, the desktop apps could just send whatever information is required when they register with the web app.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

But the web app is always running - why wouldn't the desktop apps register with it as soon as they're launched?
the desktop apps could just send whatever information is required when they register with the web app.


Yes, the web app always runs and the desktop apps should register but how does the desktop app do it? That is my query. Should I use servlet or jsp to connect to desktop app and transfer data?

What is "the system information"?


System information is something like OS installed, size of RAM, Hard disk etc. This is just a simple example for data transfer.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the web app always runs and the desktop apps should register but how does the desktop app do it? That is my query. Should I use servlet or jsp to connect to desktop app and transfer data?

Again: the web app would not connect to the desktop app - it would be the other way around. Using servlets is an option, but I think a JAX-RS service would be a better choice, as it makes things easier to implement on the server side. JSPs would in no case be involved.

System information is something like OS installed, size of RAM, Hard disk etc. This is just a simple example for data transfer.

That sounds like all this data would be known (and could thus be sent) at app startup time, so the web app never need contact the app. This significantly simplifies things.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!