Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
    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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Capture Page refresh in jsp

 
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
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

You can do something like this using javascript.



 
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • 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.

 
Marshal
Posts: 67414
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Marshal
Posts: 67414
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
 
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
Marshal
Posts: 67414
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Marshal
Posts: 67414
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
Bgg Singh,
Your post was moved to a https://coderanch.com:80/t/533201";" target="_new" rel="nofollow">new topic.
 
    Bookmark Topic Watch Topic
  • New Topic