Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

name/value

 
Higgledy Smith
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best way to populate a form from a name/value pair that is stored in a text file?

the data would look like this:
Pennsylvania-Harrisburg
Maryland-Annapolis
Virginia-Richmond
Also, can I use a dash as the delimiter?

Thank you.
Higgledy
 
Campbell Ritchie
Sheriff
Pie
Posts: 50258
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oddly enough, Iain Emsley has the same problem on another posting on this very same board. He is using a regular expression and the split method of String.
 
Higgledy Smith
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just realized that this should have been posted in the JSP forum. Is there anyone that can move it over for me? I don't want to double post.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider "Wilkes-Barre-Pennsylvania"...
 
Higgledy Smith
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would consider it if Wilkes-Barre were the capital of PA.
 
Higgledy Smith
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess maybe I should explain what I wanna do then someone might be able to tell me if it can even be done in jsp.

I have a jsp form that contains a drop-down list of all the states. When the user chooses a state, I want the capital field in the form to get populated with the chosen state's capital city. I have the state/capital pairs in a text field with a dash as the delimiter.

Any ideas would be appreciated. Thank you.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am assuming you meant text file above. You can read that into a collection such as a map. The StringTokenizer can be helpful there. Then when a state is selected, you can call a method on the backend that will return the state's capital.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be sure not to do this in the JSP itself. In fact, if the text file is not going to change much, load it into a Map in application scope at application startup.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic