HTTP or FTP for client/server application in java - java

im Trying to Write a Windows client-server Version control application .
i've created two servers , one works with java socket ( java.net library ) to handling the requests ( login, signup and ... ) coming from client . and the other server is running on FTP protocol (using apache common net library) for serving my files .
and client is able to communicate with the first server over tcp socket and download or upload files to the second server using FTP .
but recently someone just told me that i should use HTTP instead of both . because HTTP in java in really easy to use for both communicating and FILE serving and most importantly is its able to traverse the NAT which now what im using is not able to do .
now im wondering is he right ? should i change my servers to use HTTP instead of TCP socket and FTP ? whats the benefit ?

There's some advantages of changing your protocol stack to HTTP:
You can easily add security later (only a matter of a single 's')
You don't have to do two servers, you can do all-in-one.
At some point you could offer a browser-based access of you don't have the client installed / work of a decive where you cannot install it
HTTP webapps (even those in java) are proven to scale very, very well. So once you have a lot of users, you're still good to go.
There's a lot of helpful frameworks out there that can help you focus on the what instead of the how
Most companies that allow outside-access at all will have HTTP/HTTPS open. FTP is more limited in most places.
NAT traversal / Proxy traversal
and that's only the ones I came up with while typing :-)
Downsides:
You have to start over. But: If you run into trouble, Stack Overflow is there to help you out.

Related

Websocket and cross-domain

Currently, I am developing two webapps :
the core, developed in Java with Vert.x, receives data from a lot of other apps and sends it to client)
the client, developed in PHP/JS, display data from the core.
The client isn't on the same domain as my core for the production phase.
Since my development period, the two webapps are hosted in the same computer. I used "ws:\\localhost:9090" to connect my client to my core and I had no problem to transfer data.
But, today, I try to replace localhost with my IP Address and, it didn't work :s
I think that it's because the client isn't in the same domain as the core. But I don't know how I can correct this problem ?
Do you have any idea ?
Thanks !
Code example (based on my code but not my code ;) ):
For the core : http://pastebin.com/h2ZnBvQJ
For the client : http://pastebin.com/DR5BeABf
Yes, Websocket can do cross-domain, but you will need to have a handshake in order to get this going. You might want to take a look at: http://en.wikipedia.org/wiki/WebSockets for an example of a handshake.
Also related and maybe duplicate: Web sockets make ajax/CORS obsolete?

Uniquely connect an android application to a java applet on pc

I want to connect my android application to an applet which is running on my pc on Google chrome on Wi-fi.. where my phone works as a wi-fi hotspot and pc as the connected device. I want the connection to work uniquely as I want commands to be passed from my application to the specific applet, on the execution of which my applet does specific tasks. Please tell me the APIs which I can look in both Java and Android or the technology I have to use to make it work..
You need to use any program, such as wamp server, to make your computer to be a localserver. It will install PHP 5, MySQL and Apache. In other hand, you will also need a little bit of knowledge in Php language to create you own web services.
Another thing you need to be aware is that to handle you connection between server and device (and by this I mean which IP you are going to use) you will have a little headache; but first things first..break your problem in little parts thus will be easier to solve them.
I recommend this tutorial.
I think the simple way to connect these two softwares is using UDP.
It is fast, it is easy to program but it is generally unreliable according to TCP. But it is already local network. I dont think that is a case you need to take care in your local wifi network.
So take a look at this tutorial http://tutorials.jenkov.com/java-networking/udp-datagram-sockets.html
There are other ways like https://www.alljoyn.org/. It has more functinality but more complicated.
You must install Server on your PC(Apache httpd or apache tomcat or other based on your interest). A server listens to request from clients. When your mobile is connected to your pc(doesn't matter wire or wireless), you can make a request to an url(say, localhost:8080/welcome) from your app.
Create an applet and connect it with your web application(in the server) using java.net.URL and java.net.URLConnection.
On performing some operation on the client, call the url of the server application and forward the response to the applet.

Servers sending XML packet via HTTPS to each other

I think this might be a very stupid question.
I have 2 servers that are going to communicate with each other via HTTPS using XML packets.
My question is this, there is no webpage just a Java application. How would I get my Java app to run when it hears an XML packet from the other server? Are the messages to be sent via POST?
I know about HTTP protocols but my knowledge goes as far as webservers to sending the webpage to browsers, server to server communication w/o a webpage is baffling me. Can anyone point me to the right direction or better still to some codes that I might be able to look at.
Thank you.
You can use HttpClient in your server applications so that they become clients to each other. Then maybe simply implement REST services for the 'clients' to call.
I would suggest trying this out firstly using HTTP before trying it in HTTPS.
Of course there are other technologies you could try E.g JMS or SOAP.

Java RMI for implementing server side of system

I am developing system, that consists of client (written in JavaFX) and server. Now I am going to implement server. Users will download clients. Clients will communicate with server (only one server and many clients). Server will communicate with data base and send results. Server will support authentication and different requests (not http of course). Is it a good idea to implement server with Java RMI? If no, could you advice me any good idea about server realisation.
Thanks a lot for future questions!
RMI is bit kind of traditional but still powerful to me ,it has some draw back . But, despite the RMI there is also a chance for you to use java sockets class ? just like a client -server application ...

Java Servlet: Retrieve data from remote devices and "push" data to client side by using FTP connection

I believe build a small home-made program to make ourselves more comfortable is quite common nowadays. Just few days before, I really tired to get the same named log files from different remote devices through FTP connection again and again so that I started to build one Java web application.
The purpose of the Java web application is simple as once the user filled in the absolute path of source file in remote device and selected corresponding remote devices he or she want to connect to, the web application will finally store those same named log files in user's local computer with well organized folder structure. You can simply understand that this Java servlet is a proxy sits between client and remote devices.
Currently, I have already done and tested the downloading function from remote devices to the server in Java servlet by using Apache common net FTPClient library. It worked fine and provided me the copies of same named log files in a well organized folder structure.
However, when I moved on, I realized that the "pushing" function maybe the killer. Following are few queries I want to discuss with you all:
Even I could get IP address or host name from client's requests, is it possible or suitable for me to auto establish a FTP connection from servlet to client?
If an auto FTP connection is achievable, what are the security concerns I should pay attention?
If an auto FTP connection is not achievable, is it possible or suitable for me to return those files in the response to the client?
I appreciate your comments or suggestions. Hope you all also enjoy the open discussion here.

Categories

Resources