I am using struts 1 (maintenance tasks on a legacy project). The application is tiered in ActionClasses calling Manager classes and Manager classes instantiating and using DAO layer classes/
I have to code conditional logic, where based on a session variable, I want DAO layer to switch between different DB2 schemas.
How do I read session in a DAO java class? One obvious way is to refactor manager/dao class constructors to pass along session variables all through call-chain
in struts 2, we use ActionContext.getContext().getSession();
is there something like that which I can do in struts 1 ?
---EDIT For all the purists (including me)-------------
I am working on this code-base, for prototyping updated business logic. This is a code that's inherited , wrote way back in 2003-2004. After prototyping, this code will not be used at-all, going straight to recycle-bin.
I understand that DAO doesn't need to access HTTP session, and that's what I follow when i write my code.
But my question is, is there a way to access session in DAO in struts 1 framework (filters/hacks?)
The easiest is to have a thread local, maybe set in a filter or trivially-customized request processor, accessed via a static method. I feel dirty.