This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Thread programming in a Struts application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Thread programming in a Struts application" Watch "Thread programming in a Struts application" New topic
Author

Thread programming in a Struts application

Roger Jam
Greenhorn

Joined: Mar 01, 2009
Posts: 9
Hi... Can we use Java Threads in a struts web application as we do in a stand Alone application. As all the control would be under Web/Application Server , it is efficient/allowable to induce threads in a struts web application . Please Suggest.
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Which struts version you were using?
What do you want to do with threads / why do you need it actually?


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

Spawning threads is discouraged because it is safer to allow the container to manage threads. Have a look at this discussion for some alternatives.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Roger Jam
Greenhorn

Joined: Mar 01, 2009
Posts: 9
hi Mohan and Joe..thanks for your suggestions. Sorry i was not able to get back here after posting. My requirement was to send a request to data base after some update is done depending on a condition.Client wants this to be independent. He wants to proceed to other links without depending on this operation result or time . I thought of using threads,but i didnt get any assured/suitable information whether i can use threads or any other alternatives. My application is struts based and we are using JBOSS server.Please suggest.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

One strategy I've used is to use a JMS queue to communicate with a stand-alone process. The request just has to place all the required information on the queue. The JMS queue is useful because it can queue up requests should the stand-alone process fail at any time. The stand-alone process reads from the queue, executes whatever processing it has to do then it sends an email with the report as an attachment.
 
Don't get me started about those stupid light bulbs.
 
subject: Thread programming in a Struts application
 
Similar Threads
Struts
security in web application using struts,spring,hibernate
Weblogic and Struts
tiles without struts
unable to locate /WEB-INF/struts-config.xml (Struts on WAS3.5. 2)