Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multithreading in struts...

 
ritu gaur
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using struts and velocity for front end. I want to forward request to my web page which shows the progress bar and at the same time in the background some other process is going on. As soon as this process completes progress bar disappear and the msg returned by this process is displayed. I tried multithreading but
return mapping.findForward("success") returns and I am not able to get values from the previous thread in which batch process is going on.

How to do this thing.
 
Jayesh Lalwani
Ranch Hand
Posts: 502
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your struts action is going to run in the web server's thread, and the web server is going to start a thread for every requst. So, you have to start a thread that runs the background process. If you have to show the progress in the web page you can redirect to an Action that checks the progress and forwards to a jsp that shows progress. That jsp should set a imeout and rediect the user back to the checkProgressAction.

Something like this



Here, "done" goes to a page that displays "done" message. showProgress should go to a page that displays the progress bar. The showProgress should set a timeout that will redirect to the CheckProgress action after a second or so
 
Jacob Sonia
Ranch Hand
Posts: 179
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i set this timeout in my view so that after every 1 second it goes to checkprogress and then returns back with the status
 
bhavani evuri
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts 1 Actions are singletons therefore they must be thread-safe because only one instance of a class handles all the requests for that Action. The singleton strategy restricts to Struts 1 Actions and requires extra care to make the action resources thread safe or synchronized while developing an application.


Struts 2 doesn't have thread-safety issues as Action objects are instantiated for each request. A servlet container generates many throw-away objects per request, and one more object does not impose a performance penalty or impact garbage collection.


if want any information just follow the below link
http://infochannel.weebly.com/javaj2ee.html
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic