Hi all,
I've been wondering about the fact that concurrent requests to a servlet
will result in a new thread being created to access the same instance of the
servlet as long as singleThreadModel is not implemented with reference to
the following:
If you have a servlet which accesses a database, and request parameters from
an HTML form are used to build the SQL where clause, if these request
parameters are stored in class instance variables (i.e. declared at the
beginning of the class and outside of any methods, so class scope), would
this mean that there is a possibility of data being overwritten in the
middle of 2 or more concurrent requests and therefore compromising the
integrity of the data retrieved from the database?
If so, I would have thought that the way around this is to store the values
from the request parameters in variables declared inside methods, which
would then have block scope within that method.
But surely, if two requests (threads) run through this block at the same
time there is still a possibility of a problem with data integrity?
This doesn't seem quite right to me tho, because then you would have to
synchronize access to any method or variable which was used to build an sql
query or update.
Can anyone clarify?
Sorry if this is an obvious question. I've read through the documentation on
threads in servlets at Suns java site, but am still a little confused.
Thanks,
Paul
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html