Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

Spring Hello World Application

The tutorial given below describes you the way to make a spring web application that displays Hello World message on the Browser.


Spring 4 Introduction and example Features of Spring Framework 5 How to make Spring web Login form? How to make Simple form in Spring web? Spring, Hibernate login and registration application Spring Framework Tutorial for beginners with examples Spring Framework for Apache Hadoop 2.3.0 GA released Spring Framework 4.1 GA is released with major features Why to use Spring Framework? Spring Framework 4.1 - First Release candidate available Spring IO Platform 1.0.0 Released Spring 4: Login Form using Spring MVC and Hibernate Example Spring 4 MVC Login form Example with source code Spring 4 MVC Hello World Example: Spring 4 MVC Tutorial will full source code Spring Web MVC Application Error:ClassNotFoundException: DispatcherServlet on deploying Features of Spring 4 Spring Framework 4.0 released Spring Framework 4: Spring Framework 4 Tutorials and Example Spring Integration 3.0 Release is released and available for download Spring Tutorial for Beginners Java Springs Framework Tutorial Spring Architecture Spring Framework Tutorials database spring registration form Spring Login Example Roseindia Spring Tutorial Spring Tutorial Spring 3.2 MVC insert and retrieve blob from the database The hidden tag The errors tag net.roseindia.dao net.roseindia.service net.roseindia.model net.roseindia.controller Spring 3.2 MVC Hibernate Example Spring 3.2 MVC, Upload File in a specific folder Spring 3.2 MVC Form Handling The textarea tag The options tag The option tag The select tag The radiobuttons tag The radiobutton tag The checkboxes tag mvc:default-servlet-handler Static Resources Configuration View Controllers Configuration View resolvers Spring 3.2 MVC Hello World Example Content Negotiation Configuration

Spring Hello World Application


Hello World Example using Spring, The tutorial given below describes you the way to make a spring web application that displays Hello World message on the Browser.

For that we have created a file called "applicationContext.xml", which defines the bean name, their properties as well as their values.

Required fields:- 

1)class name: A class name is the implementation of the bean class that is described in the bean definition.
2)bean behavioral configuration elements: Here we define the bean behavior that is bean initialization, dependency checking mode, destruction methods etc.
3)constructor arguments and property values :-Defines the no of arguments and the property values that are to be set in the newly created bean.

Note:- We have not defined any of these behavior in our context file since we haven't created any of the bean to be used.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""


dispatcher-servlet. xml:-This is the file from which the mapping from actions to controllers is done .We have used ControllerClassNameHandlerMapping and SimpleUrlHandlerMapping classes to do such mapping. ControllerClassNameHandlerMapping class generate URL path mappings from the class names of the Controller.SimpleUrlHandlerMapping maps URLs to the request handler beans.

p:viewName="index" />:This is the ParameterizableViewController. With the use of this controller we can view the index.
p:suffix=".jsp" />:-This is  InternalResourceViewResolver. With the use of this we can map this name to an actual jsp page.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
  <bean class=""/>
  <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
  <property name="mappings">
  <prop key="/index.htm">indexController
  <bean id="viewResolver"
  p:suffix=".jsp" />
  <bean name="indexController"
  p:viewName="index" />

<% response.sendRedirect("index.htm"); %>:-This is a  method of Interface HttpServletResponse that is used to sends a temporary redirect response to the client using the specified redirect location.

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% response.sendRedirect("index.htm"); %>

index.jsp:-This is the page in which the message is to be displayed.

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>Hello World-Spring</title>
  <h1>Hello World-Spring</h1>
  <h2>Hello World</h2>

Output of the program

Download Source code


Share on Google+Share on Google+

Spring Hello World Application

Posted on: May 22, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Spring Hello World Application   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
June 16, 2011
Error in Above redirect page

rewrite index.htm as index.jsp bcoz we created the jsp rather than a html file
December 1, 2011
About Spring to jsp

I am not able to understand that is there will be web.xml and if there is web.xml then what will be servlet class. If there is no servlet-name tag will be then what should I write?