• 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

name/value

 
Ranch Hand
Posts: 193
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 193
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider "Wilkes-Barre-Pennsylvania"...
 
Higgledy Smith
Ranch Hand
Posts: 193
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would consider it if Wilkes-Barre were the capital of PA.
 
Higgledy Smith
Ranch Hand
Posts: 193
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic