I am currently working on a file conversion program, once the file has been uploaded it will convert the file to different file formats(ppt,pdf) this will usually take long depending on the file size. Since the file conversion is happening on the back end, I want the user to see the progress of the file conversion( something like progress bar eg "52% file being converted") is there anyway I can display to the user the current progress of the file conversion(that's happening on the back end)? During file conversion I am only able to show the status(in numbers(provided by the API I am using))
I have no idea where to start can someone provide some insight or approach?
If you are using Struts2 take a look at Execute and Wait Interceptor
. It creates new thread with your task which will be executed in the background while you can show some progress to the user.
In struts.xml
file add execAndWait
interceptor to your long running action and define two results wait
and success
.
<action name="longRunningAction" class="...">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="execAndWait"/>
<result name="wait">longRunningAction-wait.jsp</result>
<result name="success">longRunningAction-success.jsp</result>
</action>
You still need to poll this action in your JSP via AJAX or simple page refresh.
You're saying: During file conversion I am only able to show the status(in numbers(provided by the API I am using))
What is this number? Is percentage of how much of a file is converted? If it is, then you only need to import jQuery UI
library and add .progressbar()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With