I want to pass some values from database to populate a page with various select menus (around 5).
I can do this using JSTL SQL tag but it’s not good practice.
How can I get this data from a single servlet?
Can I send multiple lists from one servlet?
The select menus are populated from different tables. I want to use RequestDispatcher to forward the lists to the jsp.
You can use separate
ArrayListto store the various lists retrieved in the Servlet and then store each list as a request attribute as mentioned by @devsundar. You can retrieve these attributes in your JSP through therequestimplicit object.And if you want to just send all the lists in a single request attribute then @KaipaMSarma’s suggestion is good to have a
HashMap<String, ArrayList>, so your servlet code might look something like this:Hope this helps.