I am developing a Java web application. I was wondering what the advantages/disadvantages are of setting a context parameter vs just declaring a public final static variable of a class in my web application.
For example, I have a variable that is constant throughout my application such as "serviceFee". I can store this variable as a context parameter (which will mean that I can only access it when I have access to the ServletContext
Object)
or
I can set the value as a public static final variable in one of my classes (eg: my Invoice
class) (and then I'll be able to access it all of my classes without having access to the ServletContext
Object).
I'm looking for any advice on why one method is preferred over the other.
Thank you.