• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applets and Sockets

 
Udayan Naik
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applet through which i make a Socket connection to the server.Servlets on the server are making some changes to some files.Now the restraint is that at a time only one instance of this applet should be accessed at a time.I have accomplished this by using a Socket connection and polling the server repeatedly.When i close the browser window,the connection is lost and the server is free to allow another instance to open.But when i press the 'Back' button in the original window,the first applet instance re-opens and the connection to second instance is lost.How do i prevent this ? And why is this happening ?
------------------
Come on in !! Drinks are on the house in the Big Moose Saloon !!
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmmm, tricky. There are a lot of "if you 'doing/not doing' this then it could be this" things here. It seems to me that if, for instance, the socket connection was static then you won't get multiple connections and, along with this, if the actual socket connection is in a synchronized block of code then the first applet should not be able to override the second applet when it's re-initialization requests a connection. Does it work when you have applet1 and then applet2 tries to get a connection or *only* when you use the back button? Are you testing this from two seperate browsers or within one browser instance? Is the original connection being closed properly? I'm sure the solution is fairly simple, it's just a matter of tracking down the source of the problem (that sounds pretty obvious, doesn't it ). Perhaps a few code snippets could shed some light on what's going on.
Sean
 
Udayan Naik
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sean.I am testing those applets on SEPERATE MACHINES.Since my applet is modifying some the server,I want only ONE istance of that applet open on a network.That is why i am making a socket connection and polling the server.
This particular problem occurs ONLY WHEN i use the 'Back' button.
I cant post any code snippets because it's a project i am working on for a firm and they don't want the idea to go out.
We all know the secrecy these firms indulge in.
------------------
Come on in !! Drinks are on the house in the Big Moose Saloon !!
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you could try setting "Cache-Control" header to "no-cache"
to simply prevent the user from returning to the applet. This something I often do with servlets when a user may return to a cached list that they've just deleted something from. Sorry, I couldn't be more help .
Sean
 
Udayan Naik
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Sean.You've been a lot of help already.
------------------
Come on in !! Drinks are on the house in the Big Moose Saloon !!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic