-1

In my case there is a cloud server and personal application server.

I have to make a communication between both servers for accessing the data periodically.

How to create api for communication using servlet.

Is possible to use timer in servlet?

Any other suggestions?

Thanks in advance.

Amir
  • 1,066
  • 1
  • 13
  • 26
  • Will you application server fetch data from the server or the other way around? What time is it that you want to measure? – Simon Oct 17 '14 at 12:37
  • Yes my jsp application have to fetch data from the another server database. That fetching has to be happened periodically(with specific interval) – Amir Oct 18 '14 at 04:35
  • Check this [link](http://stackoverflow.com/questions/26430300/is-possible-to-do-background-process-in-jsp-using-timer?noredirect=1#comment41505502_26430300) . That question is an reflection of this question. – Amir Oct 18 '14 at 05:05

1 Answers1

3

Yes, you can user a timer within a servlet, but as Stanley suggested, web services is a layer on top of http that you can use and it may be easier.

If you just need some quick and dirty way, you can write a servlet to receive the http request in one end and some http client to do the request.

If you go Java EE, it's even easier because you can generate web services using annotations and there's already a TimerService so you won't have to reinvent the wheel.

Community
  • 1
  • 1
Leo
  • 6,480
  • 4
  • 37
  • 52
  • 1
    Check this [link](http://stackoverflow.com/questions/26430300/is-possible-to-do-background-process-in-jsp-using-timer?noredirect=1#comment41505502_26430300) . That question is an reflection of this question. – Amir Oct 18 '14 at 05:02