Hi.
To avoid spending much more time while maintaining your code than developing it, you should thing in a MVP arch.
Start by developing, for example, a servlet (Controller) that uses a wrappered Java (Bean) class (Model) to get data from DB. Later, in your JSP (View) you can ask controller for data to show at frontend.
You can get a lot of examples at Internet and different frameworks to use, or maybe you prefer build it from scratch, it's your decision.
But if you need more information, please count on us.
Here you are an example :
MVC in JSP - javatpoint[
^]
Regards