Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Populating the value into dropdown box from .propertied file

 
Nisha gowda
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to jsp. My requirement is, there is a "test.properties" file with following content

country=US,UK,UAE

On my jsp page I need to create a dropdown box using the above test.properties file. i.e dropdown should show US, UK and UAE values.

I tried using resourcebundle and string tokenizer but couldn't succeed. Can somebody help me on this?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be sure not to put any Java code in the JSP. In the controller, once you fetch and split the values into an array of strings, set that as a request scoped variable. In the JSP access that variable with the JSTL <c:forEach> tag to iterate over the string array and create the option elements.
 
Nisha gowda
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,

I did it in service class which is used by controller and was able to populate dropdown with data from properties file
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic