Trying to figure which is the best way to work with Server's Requests... and to avoid writting hundreds of lines...
hopefully using this... when i want to get the right "request" of user
at any sub i want: Dim req As ServletRequest = GetThreadRequest
and get the right request...
otherwise i must put at any sub the "req As ServletRequest" that is adding to me extra work...
is it a right way ?
having SessionFilter:
hopefully using this... when i want to get the right "request" of user
at any sub i want: Dim req As ServletRequest = GetThreadRequest
and get the right request...
otherwise i must put at any sub the "req As ServletRequest" that is adding to me extra work...
is it a right way ?
B4X:
Sub Process_Globals
Private RequestThreadLocal As JavaObject
End Sub
Public Sub SetThreadRequest(req As ServletRequest)
If RequestThreadLocal.IsInitialized = False Then
RequestThreadLocal.InitializeNewInstance("java.lang.ThreadLocal", Null)
End If
RequestThreadLocal.RunMethod("set", Array(req))
End Sub
Public Sub GetThreadRequest As ServletRequest
If RequestThreadLocal.IsInitialized = False Then Return Null
Return RequestThreadLocal.RunMethod("get", Null)
End Sub
having SessionFilter:
B4X:
'SessionFilter Class
Sub Class_Globals
End Sub
Public Sub Initialize
End Sub
Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
themodulehasit.SetThreadRequest(req)
Return True
End Sub