This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlets App Problem with refresh time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets App Problem with refresh time" Watch "Servlets App Problem with refresh time" New topic
Author

Servlets App Problem with refresh time

sitaram irrinki
Ranch Hand

Joined: Feb 16, 2005
Posts: 158
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.,
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlets App Problem with refresh time
 
Similar Threads
jQuery UI Widget issue
about weblogic container
jvm
Servlets App Problem with refresh time
about weblogic container