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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:26:16+00:00 2026-06-02T16:26:16+00:00

After the successfull attempt to upload a file the request is forwarded to his

  • 0

After the successfull attempt to upload a file the request is forwarded to his home page, the same page from where he uploaded the file. If the upload is sucessfull, before forwarding the request, an attribute is set which tells, “yes the file has been uploaded successfully!”.

The following code in the user home page is executed that aims to check if the user has to be told about the successfull upload attempt. If the user has once seen the success message in the form of alert box, the next time he should see the success message when he uploads another file successfully. But after the first attempt when I reload/refresh the page I again see the alert box telling the user of successfull upload attempt, even when I have removed the attribute from the request list.

Snippet that displays the success message to the user after a successfull file upload attempt

<script>
        window.onload = function() {
        <% message = (String)request.getAttribute("SuccessMessage");
           AttemptToUploadFile = (Boolean)request.getAttribute("UploadAttempt");
           request.removeAttribute("SuccessMessage"); // Remove the attribute so that alert box doesn't pop every time the page is refreshed
              if(message != null) {%>
                      alert("File successfully uploaded !");
                          <% } %>

        }
    </script>

Why do I see alert box again and again even when I have removed the particular attribute?

  • 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-06-02T16:26:17+00:00Added an answer on June 2, 2026 at 4:26 pm

    You’ve somewhere a conceptual misunderstanding as to how HTTP works and the “server side” and “client side” concepts.

    Request attributes are already trashed/garbaged whenever the HTTP response associated with the particular HTTP request has finished its job of sending the response body (in this paritular case, the JSP-generated HTML source code) to the client side.

    Refreshing/reloading a page in the browser (and ignoring the browser’s warning that the data will be resent!) will cause the original HTTP request data to be resent to the server and hence the server will process the entire HTTP request once again and set the request attribute once again. Explicitly removing the attribute will not solve it and makes at its own no utter sense.

    I’m not sure what’s the functional requirement is. Do you want to allow the enduser to resend the uploaded file once again? Why would you not display the message once again? Shouldn’t the enduser rather be warned that s/he is attempting to resend the file once again which is wrong in the first place? In that case, add an extra check in the doPost() method wherein you validate the filename based on the already-stored files on the disk, or some map in the session scope, and let it ignore the request and throw some exception or show a different message.

    String filenameOfUploadedFile = getItSomehow();
    
    if (isAlreadyUploaded(filenameOfUploadedFile)) {
        request.setAttribute("message", "Error, the file is already uploaded!");
    }
    else {
        // Process.
        // ...
    
        request.setAttribute("message", "File upload is successfully processed!");
    }
    

    Your JSP code can then be simplified as:

    <script>
        <c:if test="${not empty message}">
            window.onload = function() {
                alert('${message}');
            }
        </c:if>
    </script>
    

    (although I personally disagree the way of giving feedback by 90’s style alerts)

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

Sidebar

Related Questions

After successfully opening Pop3Folder , and retrieving messages from it, I then sometimes get
After successful setup on initial launch of MySQL, the page prompted me to set
I need to make a thumbnail of an image after successfully uploaded the image
The problem is right after the account locks then on the next failed attempt
After a successful Paypal transaction my customer lands on a Paypal Thank You page
After a successful login attempt my php script starts a session like this: session_set_cookie_params(1800,'/','www.mydomain.com',true);
After successfully acquiring an oauth_token for a user, I am able to get successful
after successfully building my application the start fails because it relies on config files
Currently after successful login I add md5($username) md5($password) in cookies and then every time
Hi I have a Sticky form that after successful completion I want to clear

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.