- “Node.js” is server side scripting language. It is good for Single Page Type Application.
- It is popular due to its Asynchronous Nature.
- It Can be downloaded for Windows as MSI Installer :-
- The Eclipse Plugin for Node type application project can be downloaded from :-
http://www.nodeclipse.org/updates
- This Demo, “Shows a Sample node program running in Eclipse.It Uses ‘http’ module for listening to a port”.
- Node Setting in Eclipse Window > preference ,
- Create a new Node Project in Eclipse,
- Let the Project name is “NodeJsDemo“.The Project Structure,
- The “demo_node.js” file ,
/**
* node file
* Server side script
* Listening port 9091
* It returns a string with color red
*/
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write("<h2 style='color:green'>Hi This is Sandeep.Testing Node js in Eclipse.</h2>");
res.end();
}).listen(9091, '127.0.0.1');
- Here the program Listens for port 9091 and when any request is made to localhost it returns string with HTML.