• Post Reply Bookmark Topic Watch Topic
  • New Topic

Iterate Linked List and map with the properties file value  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have `country.properties` file which have values as follows:

1=USA
91=India
20=Egypt
358=Finland
33=France
679=Fiji

and, have a response class file, which is setting a response from database to display it on `JSP` file. The value that I am getting from database is in the form of `code` or `integer`. I needed to have that value from the database and before setting the response I need to use `getProperty(code)` and save the String representation of that code into a new list and then pass that list to `setResponse`. For e.g: This is the value I am getting from database:

col1 | col2 | col3 |
1 helo done

I needed to show on my JSP page as:

col1 | col2 | col3 |
USA helo done

I was following this tutorial,http://www.mkyong.com/java/java-properties-file-examples/.
but not able to exactly understand how to achieve the same.

This is my `DAOImpl` where I needed to `iterate` and save the `mapped key-value` in a new list and then pass to `JSP` page


Any help on this would be great, as I am new to programming field.
 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the ways you could do is as follows:

From your servlet, call your DAO that sets response.
And then read property value for that country code and set value in the response object (assuming the response class has both country code and name variables).
From the servlet, set request attribute for response and forward to JSP (you can load properties file in servlet's init() method).

And in JSP, you can display what you need.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!