The applicatin I was woring on was based on JSP model 1 (JSP is responsible for processing and displaying data) developed long time ago, with JSP pages directly accessing/updating some java beans (just simple JAVA object). The data processed are from user input and session. Based on the data processing result, I found some users' data has been mixed up with the other users. How can I make the least changes to make the application thread safe? Are local variables defined in JSP the cause of the mixed data? If not considering about the scope of changes, what's the best approach for developing a thread-safe web applications (any framework?) Thanks very much for any input!!
posted 12 years ago
You gotta track down and protect shared data.
One gotcha with JSPs and servlets is instance variables. If u declare variables using <%!Declare %>, it is translated in to instance variables in the converted servlet. Instance variables in jsps and servlets are by default shared by concurrent requests. So, be careful or avoid using the <%! DECLARE %> tag for variables. I borrowed some wording from here: Discusssion on thread-safe jsps