Is it a good idea to synchronize DispathAction to make sure all requests to DB and results which come back don't overstep each other ? Pls help.
Following is some detail of what am I doing in my application. I have few operation I want to synchronize. In my app following steps I am taking 1. calling dispatch Action getInstrumentsFromQ as under, Should this be synchronized ? public ActionForward getInstrumentsFromQ(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { .. .. } 2. In Dao service I have couple of lists which are stored as Class variable, where I store one I received from DB. public class InstrumentDiceQdao extends BaseDao implements InstrumentDao{ private List instruments =(List ) Collections.synchronizedList(new ArrayList()); private List instrumentDbItems = (List) Collections.synchronizedList(new ArrayList()); public synchronized List getAllInstrumentsFromQ(Long sectorId) throws DiceWebException { ... ... } } 3. I am putting service object which has results of all DB query in Session, so I can access from various places in web. InstrumentService instService = new InstrumentDaoService(ds) ; try { synchronized(instService) { List instruments = instService.getAllinstrumentsFromQ(sectorId); session.setAttribute("InstrumentService",instService); } } This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates.