Karabo Mashiyane wrote:Thanks for the advice guys. Would also like to ask: is there a way for me to send back data to a requesting Jsp frm the processing jsp or should i consider using the jsp include action. I have been struggling to find a solution.
So you plan to ignore the advice that you thanked us for? The term "processing JSP" should be in no one's vocabulary.
1. Request from browser comes in (e.g. http://localhost:8080/myWebApp/SomeResource
2. SomeResource is ideally mapped to a Servlet which is in charge of processing the request
3. The Servlet processes the request (all the logic behind it, collecting the data that should be shown to the user, writing updates to the database etc.)
4. The Servlet is done. It wraps up all data to be displayed in beans, lists etc and puts those into the request scope
5. The Servlet forwards the request to a JSP, which is the presentation layer.
6. All the JSP does is render and display what has previously been calculated in the servlet. It does NO calculations on it's own. It's sole purpose is to display.
This way you have a clear cut between logic and presentation.
Note that this is the easiest way. In general you would strive for the MVC pattern and have the servlet be the controller and delegate the logic to external classes and services to enhance reusability.
Hope that helps, cheers.