• 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

Properties object

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering if anyone could give me an intro on Properties objects and what their uses are.
I'm making a web application and I need to be able to store a series of strings on a server and change them dynamically. I'm going to try and make a servlet, but I'm not sure if using a Properties object would be a good idea.
What are the advantages and disadvantages? How do they work exactly?
 
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
Properties sounds perfect for your needs. Start by reading the Javadoc on the Properties and ResourceBundle classes. In the servlet environment, the HttpRequest getResourceAsStream() method might also be useful.
 
Xavi Villalta
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm ResourceBundle?
I read the documentation and it seems like its used for internationalization.
I don't think I'll need a key-value system. I mostly just have an ordered list of names/Strings and I already worked out picking certain information for the necessary strings.

And for getResourceAsStream, could you explain it to me a little?
Does it get files that are in the same directory (on the server) as the applet and then create a stream from those files?
thanks
 
Bear Bibeault
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
Are you making an applet or a servlet? They're not the least little bit related.

Yes, properties are used for I18N, but that's not all they are good for. They're great of looking up strings at run-time that are stored outside of the code.
 
Xavi Villalta
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I guess I'll explain what I'm trying to make.
It's a golf betting program that people from a club are going to use.
They have to be able to access the program from the internet, so I'm going to set up a website so that they can just log in and then place their bets.
They can also change their bets before play actually starts if they want to, so this is where I need help.
I have to make an applet so that they can actually interact with the program and do what they want, but the brain classes open streams with pgatour.com and read and write to files (ex: bettor names and their choices, current rank for golfers...etc.). The point is, the files/data have to be dynamic.

I know now that applets can't normally open streams for security purposes, so I had to find a way around that. I was told that making a servlet would be the best approach, and I guess you just told me that making a Properties object would also be good. From what I've been gathering, the applet will communicate with the servlet to retrieve the necessary information and then send it back to the servlet so that it can overwrite the info in some way.

Am I on the right track here?
I'm trying to find the right way to go before I ask for help on the more specific stuff (as you can tell, I'm a newbie at all this web stuff XP)
 
Marshal
Posts: 28177
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

Xavi Villalta wrote:Am I on the right track here?



I doubt it. I think that now you have decided to write a web application, you should go back to the day before you decided "I am going to write an applet". Reconsider that decision; it's may not be the right decision. Ask yourself what in this application absolutely must be done in an applet because it absolutely can't be done in an ordinary web application.
 
Xavi Villalta
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay.
So what do you suggest that I do to display the GUI so that people can play the game.
 
Paul Clapham
Marshal
Posts: 28177
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
How would I know? I don't know anything at all about this game, and it's the first time you mentioned a game in this thread. I repeat, if it has to be done using an applet, then do it with an applet. Otherwise, don't use an applet.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic