Javatpoint Logo
Javatpoint Logo


MVC stands for Model View and Controller. It is a design pattern that separates the business logic, presentation logic and data.

Controller acts as an interface between View and Model. Controller intercepts all the incoming requests.

Model represents the state of the application i.e. data. It can also have business logic.

View represents the presentaion i.e. UI(User Interface).

Advantage of MVC (Model 2) Architecture

  1. Navigation Control is centralized
  2. Easy to maintain the large application
mvc architecture

If you new to MVC, please visit Model1 vs Model2 first.

MVC Example in JSP

In this example, we are using servlet as a controller, jsp as a view component, Java Bean class as a model.

In this example, we have created 5 pages:

  • index.jsp a page that gets input from the user.
  • a servlet that acts as a controller.
  • login-success.jsp and login-error.jsp files acts as view components.
  • web.xml file for mapping the servlet.
File: index.jsp
File: ControllerServlet
File: login-success.jsp
File: login-error.jsp
File: web.xml


mvc output 1 mvc output 2 mvc output 3
Next TopicJstl

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA