Bookmark Topic Watch Topic
  • New Topic

Capture Page refresh in jsp

 
Ramaprasad Kolla
Greenhorn
Posts: 23
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator

Hi All,

When a user refreshes a jsp page, how can we caputre it at server side?
i.e in jsp, how can we know that the current request is because the user has refreshed the page?

Thanks in advance,
Ramaprasad K
 
ujjwal soni
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

You can do something like this using javascript.



 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Report post to moderator

Hi Ramaprasad,

As ujjwal says...

You can do something like this using javascript.


But what i think using java script you can get Key board event not get how to page comes to server side.

but think java script check which key board button press. So check user press F5 button ot Ctrl+R then you get that page refresh.

That way you can get solution i think.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Firstly, you can't reliably check for this, even with JavaScript. The unload event is triggered no matter how the page is getting unloaded, and checking for keys is nonsense as different browsers use different keys and there are other ways (e.g. menus) to cause a refresh that key events cannot detect.

The real question is why do you want to detect this? It smells like a band-aid to a bigger problem that you have not clued us in on.
 
Ramaprasad Kolla
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Report post to moderator
Bear,

Its not any requirement in my project. It got to my mind whether we can capture page refresh or not.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
The answer then, is no.
 
Ramaprasad Kolla
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Report post to moderator
 
prash patil
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Report post to moderator
I got query.

In my project i want to capture the refresh event.
I used


But when i call callToMyMethod() where i get a new URL and i hit it again.
So even when I close my jsp page the unnacessay java code is being called.
Can anyone suggest any releveant way to capture only refresh?

Thanks in advance!!

PP.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
As has already been discussed in this very topic, no, there is no way to distinguish a refresh.
 
prash patil
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Report post to moderator
Just thought to share with you.
I found below link which helped me in my situation. It works for IE
Capturing windowclose


Regards,
PP
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Bgg Singh,
Your post was moved to a new topic.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!