Issue
Is it better to have one servlet running multiple tasks, or have multiple servlets?
eg. At the moment i have it like this:
ViewCarsServlet CarViewSalesServlet AddCarSaleServlet
With each serlvet handliling my requests.
But would it be better to have obne such as CarServlet. And then pass a Task variable into a If statement?
Which would be better coding practice?
Solution
It's better to have multiple servlets for multiple task. it will not affect performance as well as it is more user friendly, for a particular task we can hit separate servlet instead of making one servlet complex with lot of if else conditions, if we using only one servlet every time we need to check the conditions and then execute the respective task.
Answered By - Pri