We have a web application developed on Spring MVC and Thymeleaf, where user lands on home page with a GET request. On home page, user enters 2 parameters and make a POST request. On successful submission, a new page (lets call it page2) open which have link to let say www.stackoverflow.com. User click on the link and comes to stackoverflow page. Now if user click on browser back button, browser states that this action requires form re-submission. On click of refresh button of browser, a pop appears to confirm re-submission and confirming it successfully open page2.
The problem is client dont want to have this popup or message page, instead want to auto resubmit the page on browser back button. Since the page from where the browser back button is clicked is out of my control, please guide how this can be done.
Note - 2 parameter entered on home page(page1) is not related with any authentication or login process.
As described by CBroe PRG pattern is the correct solution. Adding this answer for those who are facing same problem.
Use this on top of php page
header_remove("Expires");
header_remove("Cache-Control");
header_remove("Pragma");
header_remove("Last-Modified");
Related
I have an app that does payment. I want to show a processing page after the user clicks the "pay" button, and then render the payment result after the payment call has finished.
If the user clicks the back button while on the payment result page, they should go back to the payment page.
The problem is if I just push the processing page into the browser history, when the user clicks the back button, they're taken back to the processing page.
I also tried replace(processingPage), but the result isn't what I want: it replaces the /payment in the browser with /processing. What I need is not having /processing in the browser history.
Is there any way to achieve this behavior with React?
Update 1
This is not my code.
An alternative is to render a processing-component on top of the payment page, but that would require lots of code changes.
I just wonder if it's possible to do the above with React router.
Try doing replace(paymentComplete) from the processing page.
Alternatively put the processing screen in a modal and don't make it a route at all.
I am creating a web application.
I have a landing page which the user sees after logging in.
From the landing page they can click a link to go to detail page.
The detail page loads data for the default id to start with. It also contains a drop down for user to pick a different id. When user presses submit button it makes a get request to the same page, but uses the optional argument id=someID this reloads the page and shows the data for the newly selected id. All of this is working correctly.
My question is, if user chooses a few different ids from the drop down and clicks submit to view their data, now if he wants to get back to landing he has to go back through each id that he viewed. I would like to know if it is possible to set it up so that when they press back button they will go directly to landing page no matter how many times they've chosen new id's to view data for.
Here is the flow I'd like to achieve:
/landing -> /detail -> /detail?id=1 -> /detail?id=2 -> [press back button] -> /landing
Have the requests on the details page pulled in via ajax. You have to do some refactoring so that on a successful request, the information it receives will repopulate like a content block, but this will allow the information on the details page to update without you actually navigating to a new page. Then it'll leave you the ability to press the back button to go back to the landing page.
If you're already using a way to catch the amount of id's requested:
<INPUT Type="button" id="back" VALUE="Back" onClick="history.go(-"number of id requests");return true;">
I have two websites (ASP.NET MVC 3, but I don't think that's very important). The first one has a button; when the user clicks that button, the site needs to make a POST call to the second website and display the result in a popup. The result is a wizard of sorts - it has several steps that require clicking buttons. The final step should close the popup.
My main problem is: how can I make the popup AND the POST? I can do a POST from the code-behind in my first site, but if I just display the resulting HTML in the popup window (replacing its content or something), the browser still knows that the page came from the first site, so the next button click tries to go to the first site. I need the popup to know its contents came from the second site.
Is this possible?
View Site A in browser. POST to Site B. Site B sends minimal HTML to browser, and that HTML creates the popup.
Does that help? Can clarify further if needed.
I am using jsp and jquery.
After logging in, the home page is displayed, but when I click on the back button of browser, it show me log in page again.
When I click on the back button, I want it to redirect to the home page, like GMail does.
Simply check if someone is logged in at the login page, and if so redirect to the homepage. No magic necessary here.
It is a good practice to check whether a user is login or not in login page. If user is login then redirect him/her to your desired page, otherwise login him.
Am doing the online cab booking services,
once user reached the successfully completed his journey,
we are showing the thank for booking and we show the booking id, some people they hit the F5
key, so page get refresh and the new entry will inserted ,
So i want to deactivate F% on my cashthankyou you page,
Thanks
Bharanikumar
You won't have much luck with this - control / detection of key presses is heavily browser dependant, and overriding standard behaviour is usually impossible.
Rather than this approach, you need to detect and appropriately handle duplicate form submission:
How to handle multiple submissions server-side
The best option is usually to find a way that don't involves tampering with browser functionality. In your case, that would be making the user submit the booking to a page that inserts the entry, and then redirects the user to a thankyou-page that does nothing more than displaying that. The user would then be able to refresh the page any amount of times, without anything dangerous happening.
You can't. This is in how the browser is coded and you can't disable it from the webpage.
You need to restructure your application to identify a refresh of this kind and not creat an additional record.
One way to do that is to check if a record was entered for the user just several seconds ago and if that is the case, not insert a new record.
Another way it to add an interstitial page that will do the adding then redirect to your confirmation page (this page is just a display page and refreshing it won't do anything).
I dont't know if you can disable the F5 but can display some kind of "are you sure" message.
This can be done using window.onbeforeunload which is called before the window reloads or gets closed.
There could be a couple of reasons they refresh the page. Maye they used their back button, double-clicked on your submit button or anything else that does the loading twice.
Here are two real solutions to your problem:
1) Put in a form field with a random number, save this number along with the booking and then check against your booking table if there already are a booking with that value. This will stop them from sending the form twice.
2) Save a cookie with the last time they completed a booking. Check this value and don't allow a new booking for i.e. five minutes.
An alternative would be to redirect your user to the thank you page, loading the ID from the session.
This way, when the user hits F5 the thank you page will load and no form submission will be attempted again.
If no booking ID is in the session when the thank you page is loading, redirect back to the home page or a suitable error page.