Given a URL, how can you tell if the referenced file is and html file?
Obviously, its an html file if it ends in .html or /, but then there are .jsp files, too, so I’m wondering what other extensions may be out there for html.
Alternatively, if this information can be easily gained from a URL object in Java, that would be sufficient for my purposes.
Just from the URL you cannot, think of the following urls:
All of them return HTML content. The only sure way is to ask the server for the resource, and check the Content-TYpe header. It is better to use to send an HEAD request to the server, instead of GET or POST – it will give you just the headers and without the content.