wood burning stoves 2.0*
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
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Calling Helper class static methods from Struts action class.
 
Similar Threads
html:image - running into an infinite loop
Bringing EJB and Struts together...
Any pattens before access EJB when using Struts
instances of an action class
Help Using static Delegates within Action classes