What better way to connect to a Web server using Java Web?

Asked

Viewed 143 times

0

I am working with a Java Web application, which will constantly take a txt file, and update this data constantly in an HTML page, but I don’t know what is the best option to connect to a web server, I should use sockets or a post connection with Ajax would be better ? I need to get a txt document on the server, constantly, and always update this data on an HTML page.

1 answer

0

As I understand it is a web server, an allocated location, with no running application that just keeps this file . txt la inside.

If on your server it is possible to implement some application you could make an HTTP GET request, so whenever accessed it would return the desired file to your other Java structure that needs it, being able to already format it and correct its presentation.

  • GET: Requires 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 it by physical path.

I believe that Urlconnection is the most basic way to do this, for simple situations solves, but for more complex cases such as Authentication, post and Multipart does not serve, so it is best to use the Httpclient (Apache Httpcomponents).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.