I have been trough this problem twice this month, I have a way to solve it, but I want have an idea of the best practice for this particular problem.
In a multilangage web application, we have a jsp-oriented Translator class to translate all the content of a web site following the current langage of the user-session. The translator use a classic Ressource Bundle. Obviously, the translator need the "request" or the "session" to get the current langage id (Locale) of the user to do his job. The "problem" occure when a lower-level class (like the database interface) need to return a error message in the current langage. At this point, the database interface dont use any request, and cannot use the tranlator. So what is the best way to solve the problem?
1) give to every class the request object in parameter? This can be anoying?
2) Give to the database interface class a "getErrorMessage" that would return the Ressouce Bundle key for the current error message? (that would need some good thread synchronization!) or put it in a "session, request" object... : we have the same problem!
So, what is the best "pattern" ?