This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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: 67595
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: 24541
168
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic