I have two jsp pages and one servlet. When user clicks submit button then processing is done in servlet and then result goes to another jsp page so that user sees his result. But I want to show a loading gif so that that gif will run till user gets his result and if in the mid time user stops that browser from loading then automatically that gif will also stop, how to do it?? In javascript or other only user will see that gif picture but when user will stop browser’s processing still that gif is running which should not happen. How can i resolve this??
index.jsp—————goes to a servlet————result.jsp
Since all of this is going to happen in the user’s browser, the solution cannot be in Java, it will have to be JavaScript, reacting to the
onabortevent.As for stopping a GIF animation, that’s not really possible (except perhaps through nasty hacks). I suggest using JavaScript (e.g. jQuery builtins or plugins) to do the animation as well.
Update: On second thought, why do you think you need to do anything at all? If the browser aborths the loading, it’s their own fault, and the browser already has a loading animation that does exactly what you want. Why duplicate that?