<div dir="ltr" style="text-align: justify;">
<p>Before developing the web applications, we need to have idea about design models. There are two types of programming models (design models)</p>
<ol>
<li>Model 1 Architecture</li>
<li>Model 2 (MVC) Architecture</li>
</ol>
<h2><b>Model 1 Architecture</b></h2>
<p><b>Servlet </b>and <b>JSP </b>are the main technologies to develop the web applications.</p>
<p><b>Servlet </b>was considered superior to <b>CGI</b>. <b>Servlet </b>technology doesn&#8217;t create process, rather it creates thread to handle request. The advantage of creating thread over process is that it doesn&#8217;t allocate separate memory area. Thus many subsequent requests can be easily handled by servlet.</p>
<div id="ads-id" align="center"></div>
<p>Problem in Servlet technology Servlet needs to recompile if any designing code is modified. It doen&#8217;t provide separation of concern. Presentation and Business logic are mixed up.</p>
<p><b>JSP </b>overcomes almost all the problems of Servlet. It provides better separation of concern, now presentation and business logic can be easily separated. You don&#8217;t need to redeploy the application if <b>JSP</b> page is modified. JSP provides support to develop web application using <b>JavaBean</b>, custom tags and <b>JSTL</b> so that we can put the business logic separate from our JSP that will be easier to test and debug.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/model1.jpg" border="0" /></div>
<p>As you can see in the above figure, there is pictured the flow of the model1 architecture.</p>
<ol>
<li>Browser sends request for the JSP page</li>
<li>JSP accesses Java Bean and invokes business logic</li>
<li>Java Bean connects to the database and get/save data</li>
<li>Response is sent to the browser which is generated by JSP</li>
</ol>
<h3><b>Advantage of Model 1 Architecture</b></h3>
<ul>
<li>Easy and Quick to develop web application</li>
</ul>
<h3><b>Disadvantage of Model 1 Architecture</b></h3>
<ol>
<li><b>Navigation control is decentralized</b> since every page contains the logic to determine the next page. If JSP page name is changed that is referred by other pages, we need to change it in all the pages that leads to the maintenance problem.</li>
<li><b>Time consuming</b> You need to spend more time to develop custom tags in JSP. So that we don&#8217;t need to use scriptlet tag.</li>
<li><b>Hard to extend</b> It is better for small applications but not for large applications.</li>
</ol>
<h2><b>Model 2 (MVC) Architecture</b></h2>
<p><b>Model 2 is based on the MVC (Model View Controller) design pattern</b>. The MVC design pattern consists of three modules model, view and controller.</p>
<p><b>Model </b>The model represents the state (data) and business logic of the application.</p>
<p><b>View </b>The view module is responsible to display data i.e. it represents the presentation.</p>
<p><b>Controller </b>The controller module acts as an interface between view and model. It intercepts all the requests i.e. receives input and commands to Model / View to change accordingly.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/model2.jpg" border="0" /></div>
<h3><b>Advantage of Model 2 (MVC) Architecture</b></h3>
<ol>
<li><b>Navigation control is centralized Now only controller contains the logic to determine the next page.</b></li>
<li><b>Easy to maintain</b></li>
<li><b>Easy to extend</b></li>
<li><b>Easy to test</b></li>
<li><b>Better separation of concerns</b></li>
</ol>
<h3><b>Disadvantage of Model 2 (MVC) Architecture</b></h3>
<ol>
<li>We need to write the controller code self. If we change the controller code, we need to recompile the class and redeploy the application.</li>
</ol>
<p> ;</p>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/introduction-to-mvc/">Previous</a> <;<; || <a href="https://dineshonjava.com/struts-2-baby-step-to-learn/">Index </a>|| >;>;<a href="https://dineshonjava.com/introduction-to-struts-2-framework/">Next</a> >;>;</b></div>
<p> ;</p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/introduction-to-struts-2-framework/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/architecture-of-struts-2-framework/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '402'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…