The servlet calls responsible the model class, which returns the data.
The servlet creates a Map where the key of each entry is the info that will become the value attribute of the options, and the value of the map entry is the display text, and places it in request scope.
The JSP uses the JSTL <c:forEach> tag to iterate through the Map and generate the option elements.
Easy as pie.
Joined: Apr 08, 2009
Sudhir Pawar wrote:no AJAX. I want simple code for retrieving data using servlet from db and show it in select list in jsp when jsp page is opening(onload event).
Page is opening != onload event
Page is opening means that is not fully open yet, onload event is thrown when the html content is ready, why would you want to load all your html and after that make a request to get the values to populate the dropdown and not using AJAX? And more important than why, how would you do that without entering an endless loop?