aspose file tools*
The moose likes JSP and the fly likes Populating the value into dropdown box from .propertied file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Populating the value into dropdown box from .propertied file" Watch "Populating the value into dropdown box from .propertied file" New topic
Author

Populating the value into dropdown box from .propertied file

Nisha gowda
Greenhorn

Joined: Feb 23, 2010
Posts: 9
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

Joined: Jan 10, 2002
Posts: 60082
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nisha gowda
Greenhorn

Joined: Feb 23, 2010
Posts: 9
Thanks Bear,

I did it in service class which is used by controller and was able to populate dropdown with data from properties file
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Populating the value into dropdown box from .propertied file
 
Similar Threads
dropdown values - change - dipplay corresponding jsp page
copy environment specific property files using ant
Reading a properties file
JSP and PropertyResourceBundle
getting this Ajax code to work with jsp