Link to home
Start Free TrialLog in
Avatar of FearFactor_x
FearFactor_x

asked on

Trapping the Browser Refresh Event in my JSP file

hi experts,
              I am developing  a JSP page in which i need to know if the user had pressed the browser Refresh. Button.
WHy i need this is because.. I have a separate Refresh link inside my window that does some thing more than just ordinary refresh..cos i am adding a few query sting parameters and reading them.. Now i need to integrate both the refresh buttons to have the same functionality.. Now how can find that the user has pressed the Browser Refresh or not.. pls let me know..

newbie web programmer..
ASKER CERTIFIED SOLUTION
Avatar of TomBruser
TomBruser

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of FearFactor_x
FearFactor_x

ASKER

the web page does not require any authentication.. So i tried to use the

if ( session.isNew () == true ) {

// Do my stuff here..


}

But the problem is that when i tried to priint  "System.out.println(session.isNew()) "; i noticed that it is always false.

1) Session.isNew() is always false for me.. even if user presses refresh
2) even if user comes back to the page thru browser back,...

Do i have to enable the sessions to use it.. Pls let me know


NewBie
Okay, look...I realize this is going to be the worst answer you receive, but it has to be said...your problem is caused by a bad design.  There surely is some other way to meet the requirements than to be over-using one JSP for so much work.  I suggest you "step back" and rethink your design, in light of what you have learned trying to implement this one.

Your efforts thus far have not been in vain, as they have exercized one design option and helped you learn about limitations of the environment for which you are developing.

Try to think about how the application might work another way that takes these lessons into account.

Also, highly recommended, do some studying and reading about web development, and design patterns/frameworks that can make your designs more robust:

http://www.programmingtutorials.com/j2ee.aspx

http://struts.apache.org/

http://java.sun.com/reference/blueprints/index.html

http://java.sun.com/blueprints/corej2eepatterns/

Please consider my post as an attempt to help, albeit not quite a direct answer to your question.

If you think I am mistaken or misguided in offering this advice, please simply disregard my post.  I mean no disrespect.