• 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

Page expired error when browser back button is hit

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am developing few portal pages using JSP. I am facing some problems when HTML form is submitted and subsequently hit browser back button. I'm using POST to send the data to the server(I cannot use GET method instead of POST according to our requirement). I need to retain all the values entered in first page for subsequent search. I am handling through by storing all the values in Request object. But when I hit back button, I am getting "page expired" error.

Please provide me some work-around for this problem.

Thanks in advance.
Sripad.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The request object gets blown away with every new request, and anyway the "request object" actually only exists on the server, not the client. The page expired "error" isn't really an "error" per se, it's just an overblown way that most browsers say "the last update was in response to a POST - you really shouldn't be going back". Unfortunately, as long as you use a POST, you're going to see this message.

One way to continue to use POST, not see the message, and keep the last search parameters would be this approach - include the search form on the search results page so the user doesn't have to go back to get back to the form, it's just right there for them to use again if they need to, and when including the search form, have a way to set the values of your form to the current search values.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i want to know is there any other way to handle the browser back button. If the user click on browser back button i want to send him to error page.
How can i do that.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sattithey botla:
Hi,
i want to know is there any other way to handle the browser back button. If the user click on browser back button i want to send him to error page.
How can i do that.



You can do it using JavaScript. Otherwise, there is no way server can recognize whether the request is the result of a back button or the user posted the same URL again, deliberately.
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi "sattithey" welcome to Javaranch ,
Please see your private messages for an important administrative matter.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sattithey botla:
Hi,
i want to know is there any other way to handle the browser back button. If the user click on browser back button i want to send him to error page.
How can i do that.



you need to prevent browser cache and maintain session properly on every page......
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
you need to prevent browser cache and maintain session properly on every page......



"page expired" means browser is prevented from caching the page, I suppose. In fact it was a POST request.
[ October 22, 2008: Message edited by: Adeel Ansari ]
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:


"page expired" means browser is prevented from caching the page, I suppose. In fact it was a POST request.

[ October 22, 2008: Message edited by: Adeel Ansari ]



HI Adeel Ansari,

you are right but,

i am suggesting to the sattithey botla's question . clearly i quoted .
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
Hi Adeel Ansari,

you are right but,

i am suggesting to the sattithey botla's question . clearly i quoted .



Even then its nothing to do with both, the browser cache and session, I believe.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sattithey,

Its not a good idea to hijack a thread. Please post your question in a new thread. It becomes quite confusing sometimes. Thanks.

BTW, your name became invalid, again.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:
Even then its nothing to do with both, the browser cache and session, I believe.


---------------------------------------------------------------------------
if you prevent browser cache and click the browser back button... the controll will go on server side .
------------------------------------------------------------------------

you believe me ? :p
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
if you prevent browser cache and click the browser back button... the controll will go on server side .

you believe me ?



And how then you distinguish, on the server-side, between the normal request and the request resulted from back button?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

hope This helps
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
hope This helps



I still didn't find the answer of my question in that thread, and my question remains. That thread is merely discussing how to prevent browser from caching.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:


And how then you distinguish, on the server-side, between the normal request and the request resulted from back button?



HI Adeel Ansari,


After pasting the above code in the jsps

when you click back button, browser understand that you want previous request to be done..so it will send the request ( in case of GET ,what you made in jsut previous request) to the server.. (request is request ..There is nothing called the normal request and request from back button)

Hope This Helps
[ October 22, 2008: Message edited by: seetharaman venkatasamy ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
After pasting the above code in the jsps


Rather than pasting the same code over and over again into JSPs (which be should be code-free in the first place) why not just do this in a filter?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
(request is request ..There is nothing called the normal request and request from back button)



Aha... Thats what I was expecting. .
Please refer to one of my previous post in this thread.

Originally posted by Adeel Ansari:
You can do it using JavaScript. Otherwise, there is no way server can recognize whether the request is the result of a back button or the user posted the same URL again, deliberately.

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
why not just do this in a filter?



Dear Bear,

Good suggestion. i know about filter,but i do not know how to use this concept in filter...

any idea or good url(link) to learn ?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
Good suggestion. i know about filter,but i do not know how to use this concept in filter...

any idea or good url(link) to learn ?



What you are doing is nothing, but modifying response headers. You can do it by configuring a filter, say invoke filter for every response.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
--------------------------------------------------
Originally posted by Adeel Ansari:

You can do it using JavaScript. Otherwise, there is no way server can recognize whether the request is the result of a back button or the user posted the same URL again, deliberately.
---------------------------------------------------------

correct .. so java script is only way? no. my point is using session also we can send him to the error page when he click on the browser back button
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:


i do not know how to use this concept in filter...

any idea or good url(link) to learn ?



Here is the link you asked for. Also take a look at this and this (a good one) .

Hope this helps
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And I am getting a feeling that this thread is getting carried away and we are losing the original question.
So please no more posts on anything not related to the original post.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Amit
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
so java script is only way? no. my point is using session also we can send him to the error page when he click on the browser back button



That question of mine stands again.

And how then you exactly distinguish, on the server-side, between the normal request and the request resulted from back button?

As a matter of fact you need to know whether the request is the result of a back button or not, before re-directing the user to error page. And you said it yourself, "request is request there is nothing called the normal request and request from back button". That means we need to employ something, be it JavaScript, to know this fact.

I suppose, you are not really getting my point, and the whole discussion is going in vain.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:
And how then you exactly distinguish, on the server-side, between the normal request and the request resulted from back button?


You could if you use a token. The first time that token is submitted is the initial request. Subsequent times are from the back button.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeanne Boyarsky:
You could if you use a token. The first time that token is submitted is the initial request. Subsequent times are from the back button.



Yeah why not. But not really, we can right click on the back button and choose how many steps we need to go back. This kind of tokens are just a workaround, in my opinion, unable to tell the exact thing. Furthermore, sometimes we ourselves make use of history.go(-1) function. One more thing, then you need to do is carefully consider the refresh attempts and count only back buttons. Hence, its better to do this stuff in JavaScript.

Nowdays, one can't imagine that the user would disable the JavaScript. Or if any user really practice this, you can ask user to enable JavaScript, in order to use the application. It will be a reasonable demand.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:
Hence, its better to do this stuff in JavaScript.



if yes, how you will do in javascript? what i feel is good session management is do the job well.

note: i expriment this scenario.

Hope This Helps
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
note: i expriment this scenario.



Ok, same question again. How did you manage to distinguish between a deliberate request from the user and a request made by pressing back button?

Even if you follow, Jeanne's suggestion you can't distinguish. All you get is a token telling you that its a request from back button, but its not a must. The user might have requested the URL in a normal way.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
if yes, how you will do in javascript?



Thats what I was waiting for. You can't really. It would be again a work-around . Choose what suits you best.

Hence, the reality is there is no foolproof method to do it, not even with the session management, nor JavaScript. As back button functionality can always be achieved by right clicking it, or by browsing browser's history.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:


Ok, same question again. How did you manage to distinguish between a deliberate request from the user and a request made by pressing back button?




why this?There is no need to know this.. once again and last i said you need to maintain session(ofcourse you need to do business logic) properly

Thanks
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
why this?There is no need to know this.. once again and last i said you need to maintain session(ofcourse you need to do business logic) properly



Can you come up with something like Jeanne did? Instead of claiming same thign again and again without any single hint. Or You may leave it.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sripad Kumar:
Hi,

I am developing few portal pages using JSP. I am facing some problems when HTML form is submitted and subsequently hit browser back button. I'm using POST to send the data to the server(I cannot use GET method instead of POST according to our requirement). I need to retain all the values entered in first page for subsequent search. I am handling through by storing all the values in Request object. But when I hit back button, I am getting "page expired" error.

Please provide me some work-around for this problem.

Thanks in advance.
Sripad.




its working.you do this .am using script.
<body onloa="backButtonOverride()">
function backButtonOverride(){
setTimeout("backButtonOverrideBody()", 0);}
function backButtonOverrideBody(){
try { history.forward(); } catch (e) {
} setTimeout("backButtonOverrideBody()", 500);
}</script>

Thanks in advance.
Ayyappan
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic