• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

MVC Architecture Using Servlet And JSP

February 4, 2014 //  by Krishna Srinivasan//  Leave a Comment

  • Java EE Tutorials
  • Servlets Tutorials
  • Servlets Interview Questions

Web Architecture Models

Different programmers may design an application in different ways. Designing an application depends on how the programmers recognize the problem and approaches for solving that problem. A development model facilitates the design process by separating the code according to the functions performed by different parts of the application.
Two types of development models are used for web applications.

  • Model-1 architecture
  • Model-2 architecture

Model-1 Architecture

Servlet and JSP are the main technologies to develop the web applications. This model uses JSP to design applications which is responsible for all the activities provided by the application. The following figure shows Model-1 architecture.
model - 1 arch

In Model-1 architecture web applications are developed by combining both business and presentation logic. In this model, JSP pages receive requests which are transferred to data sources by JavaBeans. After the requests are serviced, JSP pages send responses back to client.

Advantages

By using this model it’s easy to develop web application.

Disadvantages

  • This architecture is not suitable for large applications.
  • It increases the complexity of the program so it is difficult to debug the program.
  • It needs more time to develop custom tags in JSP.
  • A single change in one page needs changes in other pages. So it is difficult to maintain.

Model-2 (MVC) Architecture

The Model-2 architecture is based on MVC design model i.e. Model, View and Controller.

Following figure shows Model-2 Architecture.
model-2  arch

As shown in above model Servlet acts as Controller, JSP acts as View and JavaBean acts as Model. In this model, Controller receives requests which are transferred to data sources by View component and Model component. After the requests are serviced, JSP pages i.e. View component send responses back to client. These components can be described as follows:

  • Model: It represents data and business logic of the application that specifies how data is accessed and updated. Model is implemented by using JavaBeans. It has no concerns with the presentation logic.
  • View: It represents presentation logic. A View provides the Graphical User Interface (GUI) for model. It specifies how data should be presented to user in an understandable form. A user can interact with application through View and allows user to alter the data.
  • Controller: It acts as interface between view and model. It receives HTTP request. It controls all the Views associated with a Model. It receives requests from the client and delegates the responsibility for producing the next phase of user interface to view component.

MVC Advantages

  • This model is suitable for large applications.
  • It allows use of reusable software components to design the business logic.
  • It easy to maintain and test.

MVC Disadvantage

If we change the code in controller, we need to recompile the class and redeploy the application.

Previous Tutorial : Difference Between JSP and Servlet  || Next Tutorial : 

Category: Java EETag: Servlets Tutorials

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Previous Post: «servlet and jsp Difference Between Servlet and JSP
Next Post: SingleThreadModel In Servlet »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact