I would like to check if the URL given by the user is an image (jpg, png, gif). First idea: check only the file extension in the URL. The second idea: to get this resource from the server (via http get) and upload it to some Java image library to get information if this image is (serious drawback: slow). Or maybe another solution?
You should use HTTP HEAD, not a full GET. This should include a Content-Type, as the server knows. Of course, you could check the extension first, and only make an expensive / slow HTTP route if it is inconclusive.