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 7024837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:53:40+00:00 2026-05-27T23:53:40+00:00

Simpy have a JSP based website tht runs on tomcat on a machine, and

  • 0

Simpy have a JSP based website tht runs on tomcat on a machine, and is used to configure some files on that machine.

Configuration save is achieved by, clicking Save button, which kicks off a restart servlet that runs a few scripts, redirection also included with an href..

The offending code:

<a onclick="if(confirm('Sava changes?')){window.location='<%=request.getContextPath()%>/restart.do'}" href="<%=request.getRequestURL()%>#">
    Save Changes
</a>

As stated in the title, works fine under linux environment but in windows environment, the page redirects fine but the restart servlet is never fired.

Any suggestions welcome guys

  • 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-27T23:53:41+00:00Added an answer on May 27, 2026 at 11:53 pm

    In your onclick handler, you’re not doing anything to prevent the default action of the link, which is to follow the href. So although you’re setting window.location, that’s immediately being overridden by the browser following the link.

    In old DOM0 style handlers (the kind you’re using), you can prevent the default action of the link by adding a return false;. So:

    <a onclick="if(confirm('Sava changes?')){window.location='<%=request.getContextPath()%>/restart.do'; return false;}" href="<%=request.getRequestURL()%>#">
        Save Changes
    </a>
    

    …or preferably:

    <script>
    function checkSave() {
        if (confirm('Sava changes?')) {
            window.location='<%=request.getContextPath()%>/restart.do';
            return false;
        }
    }
    </script>
    <a onclick="return checkSave();" href="<%=request.getRequestURL()%>#">
        Save Changes
    </a>
    

    …or even better, look into hooking up your JavaScript handlers via DOM2-style event handling instead (addEventListener on standards-supported browsers, attachEvent for IE8 and earlier).

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

Sidebar

Related Questions

I have one form in JSP. I have some input fields in that page,
I have a tomcat based application that needs to submit a form capable of
We currently have a java/jsp online web service that includes it's own custom calendar.
I'm writing a website using JSP. I want to have the website available in
I am implementing a shopping website through JSP. I have a Java object called
I am using jsp + spring mvc, and on jsp page I have some
In WPF 3.5 (with SP1), I have simply StackPanel that I would like to
Very simply put: I have a class that consists mostly of static public members,
After being troubled by an issue that I simply did not have the knowledge
I have a very simply subclass of UIButton that will fire off a custom

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.