File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Calling Helper class static methods from Struts action class. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Calling Helper class static methods from Struts action class." Watch "Calling Helper class static methods from Struts action class." New topic
Author

Calling Helper class static methods from Struts action class.

Ramu Valivarthi
Ranch Hand

Joined: Apr 24, 2007
Posts: 37

Hi,
Iam calling a Helper class with all static methods from struts action class. My question is, if multiple requests are coming to action , the static methods in Helper holds other request's data.so is it correct to using static methods across multiple requests.
Niiraj Patel
Ranch Hand

Joined: Sep 17, 2011
Posts: 47
Ramu,

You can use static methods when you want to use it as utility method.

In short, Don't assign/change value of any static class variables to make it thread safe.

Your static methods would be safe.
--Niraj
Ramu Valivarthi
Ranch Hand

Joined: Apr 24, 2007
Posts: 37

Niraj Thanks for prompt response,

In my case the data will get changed for each request ,the flow is something like Action <--> Helper (static) <--> ServiceImpl <--> MilldeTier (Jboss EJB)<--> DAO
I just wanted to know , whether static methods will cause any issue ?
Niiraj Patel
Ranch Hand

Joined: Sep 17, 2011
Posts: 47
howdly ramu,
please have a look at this thread ..
http://stackoverflow.com/questions/5173399/are-non-synchronised-static-methods-thread-safe-if-they-dont-modify-static-class

Thanks,
niraj
Ramu Valivarthi
Ranch Hand

Joined: Apr 24, 2007
Posts: 37

Thanks Niraj
Its cleared..Iam safe now as my static methods are thread safe.



Ramu V.
 
jQuery in Action, 2nd edition
 
subject: Calling Helper class static methods from Struts action class.
 
Similar Threads
Any pattens before access EJB when using Struts
Help Using static Delegates within Action classes
Bringing EJB and Struts together...
html:image - running into an infinite loop
instances of an action class