We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

How to use loading image in Java/j2ee application

Medium Priority
511 Views
Last Modified: 2012-06-22

Hi,

How to use loading image in Java/j2ee application .  in my application i will submit the for m then i t will go to DB and do some transcation and update or insert the data . it take 10 to 30 sec ...

that time i want ask user to wait the process to complate . so i plan to display loading image how can i implement that !!
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
rrzstudent
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Author

Commented:
@colr__: @ cmalakar:

I put the image in div tag in one jsp i include that jsp in all pages ...  but the gif file is not working , if i put the image in same page then that gif file is working fine ... why ? i am understand ...
CERTIFIED EXPERT

Author

Commented:
@rrz@871311:

Most of my user are working in IE^ only . so i test the code but .. its not working ...
rrzstudent
CERTIFIED EXPERT

Commented:
>its not working ...
What happens ?
I tested in IE8. It works for me.
Did you just copy and paste my code ? ( just change the image file name and put the file along side the JSP)

Commented:
Personally I think a javascript approach is better for this type of thing:

<img src='yourLoading.gif' style="display:none;" id='theImg' />

<form onsubmit="document.getElementById('theImg').style.display='block';">
...
</form>

Open in new window


The advantage of this is that you dont have to wait for thre posted form to begin to return - the loading image will display as soon as the user hits the submit button. By doing it in java you are also moving display-related stuff into your java code, which is not a good design.
rrzstudent
CERTIFIED EXPERT

Commented:
colr makes some good points but I think it depends on the application.  It seems to me that server should be in control.
What if some of the form fields are invalid ?

Commented:
>> I put the image in div tag in one jsp i include that jsp in all pages ...  but the gif file is not working

Can you show the code.. ?
CERTIFIED EXPERT

Author

Commented:
This code in one jsp

<div id="imageDiv" >
                         
                         <img alt="processing...... " src="/x/img/cri4.gif" >  <b>Please Wait... </b>
                      </div>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" href="/xforcesTool/css/jquery-ui-1.8.12.custom.css" rel="stylesheet" />      
<script type="text/javascript" src="/xforcesTool/js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="/xforcesTool/js/jquery-ui-1.8.12.custom.min.js"></script>

<script type="text/javascript">


$(document).ready(function(){
       
      $("div#imageDiv").hide();
          
      $("a").click(function(){      $("div#imageDiv").show(); });
            });



</script>

CERTIFIED EXPERT

Author

Commented:
that above jsp inculed in my other jsp

when cilck button i call some java script method

in that method i write
$("div#imageDiv").show();

that image display but its not rotate (gif)
CERTIFIED EXPERT

Author

Commented:
any input ??

Commented:
I take it the gif rotates when viewed normally? Is the animation set to rotate indefinetly, or would it stop rotating after a specified time?

The reason I ask is that although the image is not visible as you've used hide() - the image is still there and rotating in the background. So if the gif is set to animate for only a set period of time, that time may have elapsed by the time you're calling show()

Commented:
>>$("div#imageDiv").show();

When is this being executed.. after submitting the form or before ?

You can comment out the form submission code and see, if the image really rotates or not, with the above code.
CERTIFIED EXPERT

Author

Commented:
if i put in same page means it will rotates put i inculde the image it wont rotate.

Commented:
>>if i put in same page means it will rotates put i inculde the image it wont rotate.

including one jsp in other is something that gets executed at server. Client is not aware of that includes.

All that you should see is

   1) In both include and don't include cases,  does the images urls that you get to the client are same ?

   2)  When you include another jsp, On clicking the submit button if you just show the image without form submission , does the image really rotates or not ?
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.