Q)Modify "additionapplication" so as to implement it using MVC mvcaddtionapplication numbers.html result.jsp (view component) WEB-INF web.xml classes AdditionServlet.class AdditionService.class src AdditionServlet.java(controller) AdditionService.java(model) lib http://localhost:8081/mvcadditionapplication/numbers.html //AdditionService.java(model) public class AdditionService { public int add(int a,int b) { int sum=a+b;//data processing return sum;//returning processed data to the controller } } //numbers.html(web form)

Addition form

NUMBER 1

NUMBER 2

web.xml ------------ three AdditionServlet three /add AdditionServlet.java ----------------------- import javax.servlet.*; import java.io.*; public class AdditionServlet extends GenericServlet { public void service(ServletRequest request,ServletResponse response) throws ServletEXception,IOException { int n1=Integer.parseInt(request.getParameter("t1")); int n2=Integer.parseInt(request.getParameter("t2")); AdditionService additionService=new AdditionService(); int sum=additionService.add(n1,n2);//controll talking to model request.setAttribute("total",sum);//data sharing in request scope RequestDispatcher rd=request.getRequestDispatcher("result.jsp"); rd.forward(request,response); } } result.jsp(view component) -------------------------------- THE SUM IS <%= request.getAttribute("total") %>