"Confirm Form Resubmission" problem. MVC servlets JSP javabeans - mysql

hey guys! why is it that everytime i click something on my website and try to go back one page, it says "Confirm Form Submission". Im running a local server. This is in contrast to other websites like facebook where i can go back a page without that annoying message asking me to refresh the page.

Nice Explanation indeed :
Because of the sloppy coding practices of web developers browsers were forced to add this message. the scenario is as follows:
1) user fills in form and submits (posts form)
2) the server process the post data and responds with a new page (confirm) marked as not cacheable
3) the user navigates to a new page.
4) the user press back:
for the the browser to display the page in step 2, because its marked no-cache, it must request it from the server, in other words do the repost of the data (do step 1). here is were the sloppy coding came in, if this was an credit card charge, and repost detection was not on the server, the card is charged twice. this was (is) so common a problem, that the browsers had to detect this and warn the users.
the best fix is in step two, the server sends a redirect to the confirm page. then when the user accesses the confirm via history or back, its a get request, not a post request and will not show the warning.
source : http://forums.asp.net/p/1553589/3814773.aspx

okay nevermind people. apparently i was using POST method everywhere. changing it to GET solves the problem. I think it has something to do with caching..

Related

Is there a way to safely pass queries to a non-dynamic page in NextJS?

In my nextJS project I want a feature like below:
If a logged out user want to access a url that is not for a logged out user, redirect to
login page.
After user make a successful login, redirect him/her back to the
page from where he/she was redirected.
I read about some article that were describing how to use sessionStorage or localStorage to achieve this.
I am just wondering can I achieve the same using more suitable and easy way.
I tried followings:
first I tried to achieve that using document.refferer but that doesn't seem to work with nextJS.
then,
I observed some websites [including flipkart], and sent a query parameter containing the current path when redirecting to the login page. And it works fine.
But I am getting a warning from nextJS because my login page is not dynamic hence it can not have path other than /login and /login#
Is there a way to overcome this warning ? without make it like login/[queries].jsx
Any help would be appreciated. Thanks in advance..

Getting a 302 in shell but not in browser

When I try to get a wget request of page 430 I get a redirect 302.
wget "https://www.zalando.be/kleding/?p=430"
results in
HTTP-verzoek is sent; waiting on answer... 302 Moved Temporarily
Location: /kleding/?p=429 [following...]
--2018-11-10 21:08:57-- https://www.zalando.be/kleding/?p=429
However, when I access the site and push on the button for next page, then it goes to "https://www.zalando.be/kleding/?p=430".
I don't understand how this is possible, can someone elaborate this for me?
Also is it possible to do this in the shell?
So it seems that accessing by either wget or directly writing in the browser's address bar the site's URL for p values greater than 429 will trigger a 302 redirect.
This doesn't happen while pressing the next button because in this way the page content is loaded through AJAX. This is an example of a request being made when clicking the next button: https://www.zalando.be/api/catalog/articles?categories=kleding&limit=84&offset=36036&sort=popularity
I suggest investigating the paging logic for some conditional that may trigger the redirect as an out of range page request protection.
I was wrong.
It seems that when reloading the page several times, the contents change. The fact that the browser also receives a 302 code when going to www.zalando.be/kleding/?p=430 means there is a server side "problem" with the dynamic content. I don't know how Zalando works, but my best guess is that the popularity sort throws the system off. When the system doesn't know the right amount of entries, it then redirects to page 429 (as evidenced by 431 also redirecting).
This is probably a very temporary redirect because I cannot reproduce the problem.

verify recaptcha html code

From the google site, I cam across a code that lets me display the recaptcha box. Although I must admit I have only started html today and hence, have no basics at all. The site does not have a verify code in html although it does in jsp and I dont know how to link it all since data from the html went to the servlet.
https://developers.google.com/recaptcha/docs/verify
specifis a list of parameters to be 'posted'
I am using Tomcat 7 and no Spring.
My doubts:
Can I have multiple forms in an html file
How do i send parameters from the precious form to the second form?
How do I link a jsp file that will verify it to be run through the java class invoked by the html file
How do I get the user (accessing my app through a local server) remote IP address?
Got sorted out. Since I did not understand the problem in that, I proceeded to simple captcha itself. I must admit I feel like a fool saying I din't know html/jsp. The second day it was all so clear. I must have been positively psyched. Unwilling to see the not working code again, I started fresh.
Answers :
I can have multiple forms in a html
as set and get parameter as a session and request functions respectively.
through a form itself or response.sendredirect("")
Remote address class and methods.

Trigger a web page refresh

I am working on an android application that will show an html page that contains only some text on a tablet device. The device will be on and showing this page for long periods of time(several hours). The text on this page will get changed from time to time.
To change the text on the page I've made a separate second page that contains a form to enter the new strings into and a submit button that uses ASP to generate a new version of the first page and save it over top of the original copy. This is set up and working great, but it means that I have to refresh the page very frequently in order to ensure I am always showing the latest message.
I am looking for a way that I could trigger a refresh only when a new message is saved. That way I will not have to refresh the page every minute but the new message will still get shown in a timely manner.
No dice, HTTP is built as a stateless, pull-only (ignoring file uploads) protocol. The server can't push data to the client, the client has to actually poll the server for new information.
However, you can minimize the overhead of this by using an AJAX call with JSON as the transport protocol instead of generating entire web pages and update your page on the client side. The overhead should be minimal for almost any application.
If you were just a web-app, I would suggest looking into the various Comet frameworks.
http://www.google.com/search?q=comet+framework
But, since you have an Android shell around it, you can make a Socket connection back to your server and have the server signal when it's time to refresh. It's essentially the same, but you don't need to code up the push in JavaScript if you're more comfortable in Java.

Disable page cache on a specific page

Not sure if I really am on the right forum, but if not, just tell me. I have a page that is coded in ASP (not .net) which is used to send email. We are currently having a problem in which the page seem to be sent twice sometime. Upon checking, we found out that those who have this problem are coming from big organisation, so it was suggested that their server might cache the file for some reason.
I would like to know, is there a way in HTML (or ASP ) to prevent that from happening ? Or is it in IIS that we must set this up ?
EDIT : I forgot to mention is that sometime, the time between the two mails can be in hours, not mere seconds
Thanks,
I don't see any cache problem here.
The only solution i see is to store somewhere server side(db, file system) the list of emails sent and check the list before send them.
With this approach, you will be sure to send just one mail to the specified address avoiding double submit or other possible problem.
I do not see how this could have anything to do with caching. After all, a cached page contains the generated html, and thus it would not trigger another execution of the code that sends the email.
However, my best guess is that it has to do with users that refresh the page. To avoid this, you could implement the post/redirect pattern, where after sending the mail you redirect to another page (or the same page but with different form parameters). This way the user can refresh the page as many times as he/she wants without triggering another email being sent.
If your problem is caching, there's really nothing you can do to keep an organization from caching it.
You can try to add this code to see if it makes a difference:
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
If this doesn't work, you may need to contact that organization's IT department and ask them to add a caching exception for your page/site.