Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

changing an image when uploading a file to a servlet/jsp

843840Nov 17 2009 — edited Nov 18 2009
Hi,

I am working on a web app that allows the user to upload files to a servlet/jsp. Yet, the files can be rather large, so I want to provide some type of indicator to the user that the file is being uploaded.

This may be more of a javascript question than a jsp/servlet question, but I thought I would give it a go here.

My current approach is to change some text (to say file uploading) and change an image (from a blank gif to an animated gif) once the user hits the upload button.

I created a function that seems to do the trick (if I invoke this function it works!). Yet, when I invoke the function in the context of uploading the jsp/servlet it only changes the text, but does not change the image to the animated gif. Any ideas?
<html>
    <head> <title> </title>
        <script type="text/javascript">
            function uploadChange(){
                document.getElementById('uploadText').innerHTML = 'Uploading File';
                document.getElementById('loading').src = 'loadingAnimate.gif';
            }
        </script>
    </head>
    <body>
        <form enctype='multipart/form-data' action='UploadAccept' method='POST'>
            <input type='hidden' name='MAX_FILE_SIZE' value='500000' />
            Choose a file to upload <input name='uploadedfile' type='file' />
            <input type='submit' value='Upload File' onclick="uploadChange()" />
        </form>
    </body>
    <img src="loadingSpace.gif" name="loading" id="loading" width="48" height="48" border="1">
    <b id='uploadText'> </b>
    <input type='button' onclick='uploadChange()' value='Change Text'/>
</html>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 16 2009
Added on Nov 17 2009
1 comment
258 views