• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Settings Class

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

Is there such thing as creating a settings class like I have seen in Php?
A core class which holds Static variables as settings for the rest of the webapp

It seems like most of this stuff goes in the web.xml file with Java

Just looking for some opinions on this

Cheers
Kevin
 
Sheriff
Posts: 67756
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
Yes, you could create context parameters in the deployment descriptor.

Or, you could use a context listener to place app-wide values in application context.

Or, use a properties file.

Or, use a database.

Or....

Which route makes the most sense depends upon more information than you have disclosed.
 
Kevin Tucker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Thanks for the reply.

Sorry to be rather vague, I am new to Servlets and JSP but not to Java.
I kinda have early stage questions I need to ask, and then hopefully I can pick up on the details myself through further reading.
Just need a nudge in the right direction, which I think you have now given me.

I have coded in Java for a little while for GUI apps, but mainly in Php for Webapps.
I am keen to use my Java knowledge across the board to further improve my skills & knowledge, so would like to move away from Php entirely eventually.

In Php I use a class to define static app wide variables such as DOCUMENT_ROOT, EMAIL_DEFAULT_TO, WEBSITE_URL etc etc
So I just call these in where required and only have to edit these at one place in the WebApp if required, not have to go through all the classes and code.
Was looking for something similar in Java

Regards
Kevin

 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Bear suggested it depends on the scope/requirement you want them to be placed. There are runtime scopes like request, session, context etc.. and other ways like using properties files as well. But it all depends.
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And Welcome to JavaRanch, Kevin
 
Bear Bibeault
Sheriff
Posts: 67756
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
In some projects, I have stored such values in the DB, fetched them in a context listener, and stored them in the application context where they are available to all aspects of the presentation layer.

For projects where the DB is not appropriate, I've stored the values in a properties file rather than a DB.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic