Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6603257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:59:05+00:00 2026-05-25T18:59:05+00:00

There is a html form I have which submits to a Servlet once Submit

  • 0

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/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:59:06+00:00Added an answer on May 25, 2026 at 6:59 pm

    You could try making the form target a hidden iframe and then set the onload attribute of the iframe with a javascript call to window.location.href.

    <script type="text/javascript">
    var okToRedirect = false;
    function redirect() {
        if (okToRedirect) {
            window.location.href = 'path/to/new/location';
        }
    }
    </script>
    
    <form action="...some action..." target="MyIframe" onsubmit="okToRedirect = true;">
    ...
    </form>
    
    <iframe name="MyIframe" style="display: none;" onload="parent.redirect()"></iframe>
    

    When the form posts, the results will display inside the hidden iframe. Once the iframe finishes loading, the onload attribute 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 onsubmit event on the form will set the global variable okToRedirect to true, the iframe will reload and will call the redirect() method. This time around, the redirect will occur.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 HTML submission fields under one submit button, one of which is
I am unable to determine which form submit button is clicked during an Ajax
I have a form which submits user first and last name using POST signin.html
I have a HTML form that submits to PHP. There is an onChange event
There are some HTML based games (ie bootleggers.us) that have a simple login form
I have a HTML page with a form. The form submits their address to
I have a form on an HTML page with multiple submit buttons that perform
I have two issues When I submit the character ' through my HTML form
We have a form which has a few separate submit buttons which do different
Possible Duplicate: Auto Submitting a form (cURL) I have a form which submits to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.