user28281: Actually i am trying to do IoT based work.
Until now the sensed data(temperature and humidity) has been made available to only for one user on the Internet using Apache tomcat. So far we have just created a one way communication link between the sensor node and the Internet through the PC.
Now I need to control a device (say a fan) according to the variation with sensed temperature from anywhere through the internet. For the HTML I have used Java Script, which I am new to. 

user10394: If you are planning on keeping the Arduino connected to the PC then you are looking for help with your javascript, which isn't a question for this forum.
If you are looking at making the Arduino independent from the PC then you want to look at possible network options for the Arduino, ESP8266 shield, Mobile phone, C5100 (?).  
Of course you might also want to look at using an ESP8266 rather than an Arduino and programming that through ArduinoIDE and using its web server rather than Apache.  There are samples that would show you how to do this, you could get them without getting the hardware, but obviously they won't run.

user16085: Perhaps a message brokering service like MQTT is what you are looking for. Far too much to it to explain it all here, but basically it lets you publish messages and subscribe for messages, over a network.

28281: <p>Actually i am trying to do IoT based work.</p>

<p>Until now the sensed data(temperature and humidity) has been made available to only for one user on the Internet using Apache tomcat. So far we have just created a one way communication link between the sensor node and the Internet through the PC.</p>

<p>Now I need to control a device (say a fan) according to the variation with sensed temperature from anywhere through the internet. For the HTML I have used Java Script, which I am new to. </p>
 10394: <p>If you are planning on keeping the Arduino connected to the PC then you are looking for help with your javascript, which isn't a question for this forum.</p>

<p>If you are looking at making the Arduino independent from the PC then you want to look at possible network options for the Arduino, ESP8266 shield, Mobile phone, C5100 (?).  </p>

<p>Of course you might also want to look at using an ESP8266 rather than an Arduino and programming that through ArduinoIDE and using its web server rather than Apache.  There are samples that would show you how to do this, you could get them without getting the hardware, but obviously they won't run.</p>
 16085: <p>Perhaps a message brokering service like <a href="http://www.hivemq.com/blog/how-to-get-started-with-mqtt" rel="nofollow">MQTT</a> is what you are looking for. Far too much to it to explain it all here, but basically it lets you publish messages and subscribe for messages, over a network.</p>
