Once I have came across a pattern, where ServletRequest
and response objects are put to servlet\'s local ThreadLocal
variables. The servlet class h
I'm not 100% sure what was the intention of the author of the code you'd once came across, but I guess the idea there is that ServletRequest
instance is available from any method in the code without passing it as parameter or setting as instance variable. Usually ThreadLocal
variable is static and there is a method exposed that allows to obtain the instance of ServletRequest
in statically. For instance you could access ServletRequest
in Struts FromBeans easily using this technique.