What is the best way to connect to a web server using Java Web?

0

I'm working with a Java Web application, which will constantly grab a txt file, and update that data constantly in an HTML page, but I do not know what the best option to connect to a web server, should I use sockets or a connection per post with Ajax would be better? I need to get a txt document on the server, constantly, and always update that data in an HTML page.

    
asked by anonymous 10.04.2017 / 21:31

1 answer

0

So I understand it's a web server, a local allocated, no running application that just keeps that .txt file inside.

If you can implement an application on your server you could make an HTTP GET request, so whenever it is accessed it would return the desired file to your other Java framework that needs it, and you can even format it and hit your presentation.

  • GET: Request a representation of the specified resource. (The same resource can have multiple representations, for example, services that return XML and JSON.)

Now if it is not possible to create this application on the server and the file is available for access, you could search for it by the physical path.

I believe URLConnection is the most basic way to do this , for simple situations it solves, but for more complex cases such as authentication, post and multipart it does not work, so it's best to use HttpClient (Apache HttpComponents).

    
11.04.2017 / 15:32