I am working on a application which allows user to download JARs which is actually a PDF player displaying some PDFs which are downloaded as a part of JAR itself.
Now whenever users clicks on that JAR File, I want to validate the PDF Bundle on the server (whether it got expired? Or a new version is available). Also, I want my PDF Content to get updated if a new version of the downloaded bundle is available. So I will need to download the PDFs from the server if a new version is there.
So I want to make a HTTP Request to the server from inside my JAR & receive some PDFs (and some additional data as well) as response.
Any idea how I can do this? Is there some API available for creating HTTP Requests from a plain Java Program?
Send an HTTP request by creating a URL and getting the connection for it, and casting it to HttpURLConnection.
Add an “If-Modified-Since” header, with the download date of your local file. If the server responds with 304 (not modified), then your local version is up-to-date.
If the local version is not up-to-date, the server will respond with the actual content, which you use to update your local cache.