• Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamic dropdown list in jsp

 
RaviSingh Kumar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am new to JSP. I have to show District dropdown values based on Region selected from dropdown. Both values are stores in Region and District table in database.

Please let me know how to proceed. I am stuck as how to get all the values of district of particular region and then to show it in jsp page.

Thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your page controller, call the Model method in your business layer that returns the List of values. If your <option> elements are to have different value attributes than display text, a Map rather than a List may be useful.

Place the List (or Map) in the request scope and forward to the JSP.

Within the JSP use <c:forEach> to iterate over the List (or Map) and emit the <option> elements.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!