NodeJs Hello World Project

HelloWorld Example 

main.js

/**
* nodeJS is JavaScript-based framework/platform built on Google Chrome V8 Engine.
* It is used to develop I/O intensive web application 
* like video streaming sites, sigle-page application. 
*/
var http = require("http");
http.createServer(function(request, response){
 response.writeHead(200, {'Content-Type': 'text/plain'});
 response.end('Hello World\n');
}).listen(8080);
console.log("Server is running on http://localhost:8080/");

Command to start server

node main.js

 

Simple Spring Security Web Application Example – web.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:security="http://www.springframework.org/schema/security"
 xsi:schemaLocation="
 http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context.xsd
 http://www.springframework.org/schema/security
 http://www.springframework.org/schema/security/spring-security.xsd">

 <context:component-scan base-package="com.ittechoffice.example.controller" />

 <!-- Spring MVC Config -->
 
 <!-- Add support of JSP -->
 <bean
 class="org.springframework.web.servlet.view.InternalResourceViewResolver">
 <property name="prefix" value="/WEB-INF/jsp/" />
 <property name="suffix" value=".jsp" />
 </bean>
 
 <!-- Spring Security Config -->
 <security:http auto-config="true">
 <!-- P.S. "**" means zero or more directories in the path -->
 <security:intercept-url pattern="/**" access="hasAuthority('ADMIN')"/>
 </security:http>
 
 <security:authentication-manager>
 <security:authentication-provider>
 <security:user-service>
 <security:user name="user" password="password" authorities="ADMIN"/>
 </security:user-service>
 </security:authentication-provider>
 </security:authentication-manager>

</beans>

 

web.xml Template

 

<web-app id="WebApp_ID" version="2.4"
 xmlns="http://java.sun.com/xml/ns/j2ee" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
 <display-name>Spring MVC Application</display-name>

 <servlet>
 <servlet-name>HelloWeb</servlet-name>
 <servlet-class>
 org.springframework.web.servlet.DispatcherServlet
 </servlet-class>
 <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
 <servlet-name>HelloWeb</servlet-name>
 <url-pattern>*.jsp</url-pattern>
 </servlet-mapping>

</web-app>