• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Message between two servlet page

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a requirement, I need to build a servlet page which take input of key in encoded format containing user id, access and page id. when two users enters the page second user should get a popup that another user is already in the page (I have stored the user already in a page in DB and when second user goes to the page I am able to retrieve from DB and show the message and make the page as read)
I am stuck at fulfilling below request
second user can request access upon which first user should get message to approve it. If the first user agrees then second user should get a message back to continue work and first user will get have the access as read and second should have access of write.
 
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTTP doesn't work that way.

It's easy to use the DB as a place to store state, but immediate notification and handshaking is more difficult. You'll either need to poll from the pages, or limit your audience to modern browsers and use constant-connection technology. Either way, it's not an easy thing to set up.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Prasad B Rao, Welcome to the Ranch!
 
Saloon Keeper
Posts: 27489
195
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlets are not "programs". They are not continuously-running tasks. They are, in effect, "subroutines" that get called when a web URL request comes in and they are expected to process and exit as quickly as possible. The only time that 2 users would simultaneously be executing a servlet's code is if they had made simultaneous web requests, in which case they would each be running under separate temporarily-assigned threads.

What you are describing is a lot more complex than you realize - it's a workflow (business process) that requires the actions of 2 separate agents.

Such things are hardly unknown, but it's not something you get from some simple hand-waving "All You Have To Do Is..." process or brute-force stomping around in servlet code. At a bare minimum, you're probably going to need some sort of transaction management on your database, and there are entire frameworks and standards custom-designed for this kind of stuff when really serious workloads are required.
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic