• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Iterate Linked List and map with the properties file value

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
There is no "i" in denial. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic