I have written a servlet java program.
During the execution of one particular loop of the program, I need the a gif file to be displayed in the JSP form indicating that the process is going on.
I am not aware of implementing the same inside the loop.
Kindly advise on how the same has to be done, such that a gif file is displayed in the JSP form and it would be of great use if u can suggest any .gif file for the purpose of processing display. Am a beginner in java.
Thanks in advance
JSP is supposed to output HTML. Images in HTML are to be displayed using
<img>tag. This tag has asrcattribute which is supposed to point to a public web resource. Here’s an example:When opening the JSP page by http://example.com/context/page, this assumes the
progress.giffile to be present in http://example.com/context/progress.gif (i.e. in the root of the public webcontent folder).Now, you want to display the image only when the submit button is pressed in order to wait for the response to be finished. You can do this by initially hiding the image using CSS and redisplaying it using JavaScript.
HTML:
CSS:
JavaScript
When the response is finished, it will refresh the page with the new target page and the progress image will “automatically” disappear.
Update: here’s how the complete JSP file can look like:
Or when CSS/JS is externalized in its own file (recommended):
See also: