sizzledgooseSoftware and s/w Development

Nov 3, 2013 (3 years and 5 months ago)



Faculty of Art and Science
Department of Mathematics and Computer Science

MCS491 Graduation Project I


Adem Dilbaz 200822015
Hakan Erdem Aydan 200822007

Instructor: Gülistan Özdemir Özdoğan

Jan 2013 ANKARA


- Introduction
- Objective
- Programming Environment
- The Structure of Spring MVC Web Applications
o DispatcherServlet
o ApplicationContext
o Java Server Pages (JSP)
- Simple Example of A Spring MVC Application
- Conclusion
- References


The Spring Framework is an open source application framework and Inversion of
Control container for the Java platform.
The first version was written by Rod Johnson, who released the framework with the publication
of his book Expert One-on-One J2EE Design and Development in October 2002. The
framework was first released under the Apache 2.0 license in June 2003. The first milestone
release, 1.0, was released in March 2004, with further milestone releases in September 2004
and March 2005. The Spring 1.2.6 framework won a Jolt productivity award and a JAX
Innovation Award in 2006. Spring 2.0 was released in October 2006, Spring 2.5 in November
2007, Spring 3.0 in December 2009, and Spring 3.1 in December 2011. The current version is
The core features of the Spring Framework can be used by any Java application, but there are
extensions for building web applications on top of the Java EE platform. Although the Spring
Framework does not impose any specific programming model, it has become popular in the
Java community as an alternative to, replacement for, or even addition to the Enterprise
JavaBean (EJB) model.


Our aim was to recognize Spring Framework under Java Platform. Our Graduation Project was
generally based on research and analyzing written sample programs which are used Spring
Framework. We run this applications on NetBeans Integrated Development Environment (IDE).
We also aimed to analyze Spring Form applications with Spring MVC and created a form-based

Programming Structure
Programming Language: Java, HTML codes
OS Platform: Windows 7 Professional
Data Architecture: Spring MVC (Model and View Controller)
IDE : NetBeans IDE 7.2.1
Server: Apache Tomcat 7.0.32


The Structure of Spring MVC Web Applications
1- DispatcherServlet Configuration

In Spring’s Web MVC Framework the mechanism of dispatching the request to the
appropriate controllers is achieved by configuring the DispatcherServlet class.
DispatcherServlet is the class which manages the entire request handling process. Like a
normal servlet, DispatcherServlet also needs to be configured in the web deployment
descriptor (web.xml). By default DispatcherServlet will look for a name dispatcher-
servlet.xml to load the Spring MVC configuration. Spring’s DispatcherServlet is
completely integrated with the Spring ApplicationContext and enables to use all the other
features of the Spring. The example in Figure 1 will explain about DispatcherServlet and
its configuration.

The Spring Web Model-View-Controller (MVC) Framework is designed around a
DispatcherServlet that handles all the HTTP requests and responses.

Figure 1: Default bean declaration on DispatcherServlet.xml

The request processing workflow of the Spring Web MVC DispatcherServlet is illustrated in the
following diagram:

Figure 2 :The working process of DispatcherServlet.xml

1. After receiving an HTTP Request, DispatcherServlet consults the HandlerMapping to call the
appropriate Controller.
2. The Controller takes the request and calls the appropriate service methods based on used
GET or POST method. The service method will set model data based on defined business logic
and returns view name to the DispatcherServlet.
3. The DispatcherServlet will take help from ViewResolver to pickup the defined view for the
4. Once view is finalized, The DispatcherServlet passes the model data to the view which is
finally rendered on the browser.


2- Application Context

The ApplicationContext is Spring's more advanced container. Similar to BeanFactory, It can
load bean definitions, wire beans together and dispense beans upon request. Additionally, it
adds more enterprise-specific functionality such as the ability to resolve textual messages from
a properties file and the ability to publish application events to be interested event listeners. This
container is defined by the org.springframework.context.ApplicationContext interface.
The ApplicationContext includes all functionality of the BeanFactory. It is generally
recommended over the BeanFactory. BeanFactory can still be used for light weight applications
like mobile devices or applet based applications.

Figure 3:The working process of ApplicationContext.xml


3- JSP(Java Server Pages)

Java Server Pages (JSP) technology enables Web developers and designers to rapidly develop
and easily maintain, information-rich, dynamic Web pages that leverage existing business
systems. As part of the Java technology family, JSP technology enables rapid development of
Web-based applications that are platform independent. JSP technology separates the user
interface from content generation, enabling designers to change the overall page layout without
altering the underlying dynamic content.

Figure 4: The working process of View Pages (JSP)


Simple Example of a Spring MVC Application
We created a simple MVC project that includes Spring Form usage. In our project, we have
created a ModelAndView object and it returned in the method of onSubmit().

By setCommandClass(), attributes and get & post methods were imported to the
By setFormView(), we defined our first screen as nameView.jsp which data is entered by the
user and transferred to the second screen.
By setSuccessView(), we defined our second screen as helloView.jsp .

Figure 5: HelloController.java

On nameView.jsp, we created text, password, checkbox and submit types.
We got these information on nameView.jsp and posted it to the screen on helloView.jsp.
We got the paths nameN and passwd portions by ${status.value} and transferred to another
screen with Spring form.

Figure 6: nameView.jsp


On helloView.jsp, we printed data which were written on nameView.jsp, name and password

${helloMessage} for attribute name “name”.
${sayPasswd} for attribute name “name”.

Figure 7: helloView.jsp

On Name.java class, we declared attributes nameN, passwd, chk and getter & setter methods
of them.
On HelloService.java class, we declared methods to print to the screen ;
sayHello() to print name attribute.
sayPass() to print password attribute.

Figure 8: HelloService.java

When we run our Project, the output is shown below.

Figure 9: http://localhost:8090/HelloSpring/hello.htm

If the form is submitted, you are redirected to the result page.

Figure 10: http://localhost:8090/HelloSpring/hello.htm



In our project, we used Spring Web MVC. While coding the simple project, we have on Java
Programming Language around NetBeans IDE with Apache Tomcat as a server. Firstly, we
researched about Spring Framework on different platforms such as forums,blogs, articles and
tutorials about Spring Framework. We found lots of Spring Web examples and tried to run and
analyze them. After that, we created some Spring Form applications and tested. As a
conclusion, we acquired detailed information about Spring Framework and this practice
provided a good infrastructure for us. With these experiences, we believe that we will prepare
an efficient Spring Web Application Project next term.