Servlet : Usage of Constants.java class vs context param
Posted
by
Pongsakorn Semsuwan
on Programmers
See other posts from Programmers
or by Pongsakorn Semsuwan
Published on 2012-10-02T08:49:37Z
Indexed on
2012/10/02
9:49 UTC
Read the original article
Hit count: 271
java
|web-applications
I'm just wondering whether to keep some of my variables in Constants class or keep it in web.xml
Say, I want to keep a variable of Facebook graph API prefix or api_key
, client_id
From my understand, the difference between Constants.java and web.xml is web.xml is easier to rewrite on compile using ant.
So, you can replace your variables in web.xml according to what environment you are building you app for. (client_id
varies by development environment/production environment, for example)
If I understand it right, then Facebook graph API prefix should be kept in Constants.java (because it always is "https://graph.facebook.com/") and api_key
, client_id
should be kept in web.xml?
What's the proper way to use them?
© Programmers or respective owner