There is a html form I have which submits to a Servlet once Submit button is clicked. After the submission the Servlet redirects to a fixed url which is
http://siteforServlets.com/Servlet/Servlet
That site then displays an xml report shown below:
Sorry I cannot post Images not enough rep so I uploaded direct link here:
http://img836.imageshack.us/img836/3343/sitea.png
I dont want my users getting confused seeing an xml I prefer it going blank page or redirecting to a different url…
How can I redirect the url to hide this xml report url?
Mark, I tried what you said but it redirects before the form even loads. Here is a quick jsfiddle I made to demonstrate your suggestion: jsfiddle.net/ujsEG/12/
You could try making the form target a hidden iframe and then set the
onloadattribute of the iframe with a javascript call to window.location.href.When the form posts, the results will display inside the hidden iframe. Once the iframe finishes loading, the
onloadattribute will fire the javascript to redirect the user.Update
I updated my answer because of your comment. I added a javascript method which the iframe can call. There is now a global variable which is set to false initially. This will prevent the first load of the page from redirecting. When the form posts, the
onsubmitevent on the form will set the global variableokToRedirectto true, the iframe will reload and will call theredirect()method. This time around, the redirect will occur.