0

I know java.nio.file package provides a file change notification API (Watch Service API).

I need similar kind of service for getting notifications anytime a website is changed. Besides polling or some api built on top of polling, is there a library/API available? If no, how can I do better than periodic polling (or alternative)? If I am forced to do polling (because there are no alternatives), is there some tag in http/html message that tells me when the website was last modified so that i can detect the change without parsing entire website content and comparing with last read for detecting modification changes

kashili kashili
  • 955
  • 4
  • 15
  • 31
  • 1
    There's http headers for last-modified and whatnot, but the only way you'll GET those headers is by polling the web site. Some sites may offer a "push" version to notify of changes (e.g. like SO does for updates/messages), but that's a per-site thing, and not in any way "standard". – Marc B Feb 15 '14 at 01:27
  • @March..thanks for http headers. I am reading from internal website. How would I make this website to push changes to my java code (or to any external party outside website) – kashili kashili Feb 15 '14 at 01:34
  • 1
    comet/longpolling is one way, websockets are getting "bigger" and more standard. – Marc B Feb 15 '14 at 01:35
  • thanks @Marc for sharing the terminology for what I am looking!! Here are some relevant links http://stackoverflow.com/questions/16010701/how-push-notification-java-servlet-for-web-application and http://stackoverflow.com/questions/11077857/what-are-long-polling-websockets-server-sent-events-sse-and-comet?lq=1 – kashili kashili Feb 15 '14 at 03:35
  • 1
    WebSockets can help here http://stackoverflow.com/questions/10377384/why-use-ajax-when-websockets-is-available. You can also use MQTT protocol over the web sockets. – Neeraj Krishna Feb 15 '14 at 03:45
  • the website I am trying to download sits on embedded device (Arduino based). I can not put big software stack on it. So far I have only webserver and AJAX on the device. However these were good suggestions/hints that I should educate myself – kashili kashili Feb 15 '14 at 03:49
  • 2
    You should also look into the HTTP HEAD method, which (IIRC) doesn't return any content, but only the headers associated with a request. This may enable you to read the the last-modified header without having to download the entire page. – Henrik Aasted Sørensen Feb 17 '14 at 14:28

1 Answers1

0

I came across cwebsockets, websocket implementation for Arduino platform

https://code.google.com/p/cwebsocket/

kashili kashili
  • 955
  • 4
  • 15
  • 31