• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session corruption........

 
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai All!

Here is my problem... I have a form ..If i click submit button in that form request is generated and it is processed by server side component. This process includes reading and modifying an object stored in the session object. Problem is when user clicked submit times multiple times (quickly) some 3to 4 requests are generated and all requests is trying to modify object stored in session object and object is getting corrupted.
I need some solution this.. I don't want to disable submit button as i have some GUI desing restrictions. Also i don't want to use synchronize blocks as they tend to slow the program..What i need is some sort of terminating those extra requests generated. Is it possible to do so? if so how can we accomplish this and what are side affects of this?
If only solution is going to Synchronize blocks then pls suggest how best we can do it as the server compoent under consideration cannot be afford to be slowed down due to some real time considerations..
Any suggestions are most welcome..
TIA
Rgds
Manohar
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This problem is discussed in Core J2EE Patterns (I can't find a link at the moment). I can't remember what they suggest, but these might help...
If you use a Model-View-Controller pattern with a global controller, you can use a "current page" concept to ignore the fact that they submitted the form twice since you know they shouldn't be there.
You can also use a form tag - write a hidden value to the form with a unique value for that user, if you receive the key twice then you can ignore it.
Dave
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai!
Thanks for ur reply...I followed that approach..We are following MVC pattern and is not processing the request if same request is already under processing.
In JSP i am using custom Tag Handlers so that they process the display content and write back to JSP writer...
In case of multiple requests (As i explained above..) that writing to browser is throwing exception :
java.net.SocketException...
Any help is appreciable..
Rgds
Manohar
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the request is taking too long, the browser has to wait till something gets returned before it can change its display. When this is a long time, the user sometimes presses the submit button again.
When this happens, the browser breaks the connection to the server and starts again. The server can't tell this has happened till it tries to write to the browser, finds that the connection it was expecting doesn't exist, then throws the exception.
Meanwhile, the second request continues.
What I like to do (apart from making the processing more efficient) is to throw up a temporary "Please wiat" page while waiting for the server to respond.
Rather than having the first page submit to your processing, it submits to a dummy page that returns a "please wait" message, embeds the form data as hidden fields and auto-submits the data to the "real processing" page. This request takes a while, but the user has a nice page to view and can't press the button again.
Does this help?
Dave.
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai!
Idea is nice...But is it possible to do something without touching the pages..Like to try it on server side..
Rgds
Manohar
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not really, cos as soon as they hit the submit button again the browser kills the old connection. The only other semi-acceptable way is to have a javascript flag in the page that gets set a stops the submit button from working. (this solution has a bunch of problems as well)
Looks like you might have to have another look at the processing being done and solve the problem from that point...
Dave.
(just for the record, I have to leave for the day. I hope you get your problem solved )
[This message has been edited by David O'Meara (edited December 04, 2001).]
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai All!

This is more or less repetition of my previous query,,I cannot change my pages due to some cinsiderations.. Now is there anyway i can handle the situation of multiple requests?
RGds
Manohar
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Like is there anyway to know that connection is terminated as soon as it is terminated?
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. HTTP is stateless.

your server side is completely and blissfully un-aware of what is going on at the client.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, a solution I came up with just after walking out the door is this:
(this will only solve the problem with ppl pressing the submit button, it won't stop them reloading etc.) I'd also like to say I don't like this solution and I'm not positive it will work, but I can't think of a reason why not...
As soon as your Servlet begins, send some white space down the InputStream and flush it. (send a bunch of spaces of carriage returns) This should clear the page at the client side so they can no longer press the submit button.
Dave.
reply
    Bookmark Topic Watch Topic
  • New Topic