Many of my servlet's methods use HTTPSession. Is it thread safe to declare an HTTPSession variable as an instance variable?
Using defaut, Servlets are not thread safe . Moreover, a servlet instance will be called for many clients. It is absolutely wrong to have a session as an instance variable.
Link:
Is safe for servlet
Create thread-safe servlets
No, this is not safe. when the application starts, a servlet is created. A servlet has only one instance (this means that multiple requests / clients use the same servlet), so you should avoid any instance variables.
Source: https://habr.com/ru/post/1400964/More articles:PDF Interactive Charts - javaWhat does the "-" operator actually do on Linux? - linuxCan I create DWORD registry keys using wix? - wixSlicing a python regex string using named groups and wildcard - pythonVariables declared outside the init () method in servlets - javaWant to read the key value from properties File - javascriptOnScrollListener.onScroll () caused by clicking an item in a ListView - androidHow can I get the CGRect x, y, width, height values ββafter the view is authorized? - iosTinyMCE Button Press Event - tinymcePHP PDO Bit (1) returns invalid data type - phpAll Articles