In servlets suppose we are using a flight reservation application in that case every second the number of users update the database than user sends the request to the server the server sends response to creating an object in server than every second every request will be sent to the server and correct to the database every time this time taken we can use cache we can not give the acurate result .So how we can solve the problem.,
If I understand your question correctly, you are asking how do you keep a database accurate when multiple users can take actions that affects the DB.
Let say, using your flight reservation system, that there is only one seat left on a flight, and two users are looking at available seats for that flight simultaneously.
Are you asking if user #1 books the flight, how do we notify the user #2 that there is no longer a seat available? Given the request/response nature of the web, there really is no way to do such. User #2 will not know that last seat was taken until he either reloads his page, or goes to reserve that last seat, and the system sees that it has already been reserved, and tells the user it is no longer available.
Now if your question goes a step farther, and ask how do we prevent both users from creating a reservation for that one seat over booking the flight if they both hit the "submit" button on the reservation page simultaneously, the answer becomes a little more complicated, but not much since database systems need to deal with this type of thing all the time. It goes to the heart of working with databases.
As a basic overview of what needs to occur, you need to synchronize your database updates so that two different instances of the servlet (the one for User #1 and the one for User #2) do not both make the reservation. And within your synchronized code, you need to first check the database to verify a seat is available, before you actually make the reservation.
This answer is a bit of a high-level overview of what needs to occur, but I hope it answers your question.