Hello I am trying to implement the MVC architecture using JSP(view), Servlet(Controller) and Java classes(Model).
I have named my Application as First_App.In this application there are 2 JSPs namely First.jsp and Second.jsp.
To implement the controller, I have written a servlet whose job is to analyse a request for any page in this application and perform the following tasks:
1. Create an object of the model class,
2.Call one of its methods that will fetch data from a database,
3. Create an instance of a bean
4. Call its respective setter methods to set the attribute values with the retrieved data
5. Set the bean as a request attribute.
For forwarding request parameter to JSP page from within servlet, you need to set that param in request object using:
Also, map your actions like:
1) From JSP:
<form action="user" method="post">
2) Make appropriate entry in web.xml like:
3) In Servlet, override doPost()/service(), write your business logic and forward it to other JSP accordingly.