Is it necessary to write a corresponding servlet for each JSP page in case of MVC Architecture?

Recommended Answers

All 2 Replies

Nothing is necessary. You can write anything you want in any way you want. In the end it is experience that will tell you when it is better to use servlet to handle the request from the jsp file or just just handle it in the same page by setting action in the form tag to be:
<form action="" ....> If you need to use and declare a lot of methods in order to use them then you use servlets. Or in some cases you can have more than one jsp (whose requests have a common behavior) to go in ONE servlet, handle the request, and then depending on the results you can have more than one selections as in which jsp to go next.
If you need to submit a form and then just display the results in the same page, then one jsp that submits to itself is enough.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.