>>> Arnab Nandi <[EMAIL PROTECTED]> 20-Jul-01 2:13:15 PM >>>
Can someone tell me why the servlet spec advises
that programmers should not synchronize any of the
doXXX() methods or the service() method that
they override in their servlets?
This has been explained about a zillion times on the list. Check the
archives.
A quick answer is that if you synch your doGet then your servlet can
only execute for one client at a time. Is that what you want?
Consider a service using your servlet with 1,000,000 users. Those
users won't appreciate it very much if only one of them can use your
servlet at any one time.
I have to take care of concurrency in my application.
How do I do it except synchronizing the method?
By synchronizing access to the things that might cause contention.
Basically, I have to query an Oracle database, which
selects the nextval() from a sequence. My problem is
suppose two users make a query at the same time from
two different connections in the connection pool,
they may end up getting the same no. from the sequence.
It depends on the database driver. It should probably synchronize
access to the database for you.
As I say, these issues have been gone over many, many times. Check
the archives of this list.
Nic
___________________________________________________________________________
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