Amrinder Kalsi
Amrinder Kalsi

Reputation: 13

Why Struts 1 same Action method get execute one after another when it get called at same time from two browser?

public ActionForward doSearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {

     //Logging
     System.out.println("Inside doSearch for job | Date: " + new Date());

     //doing search operation
     listJobCard = getDaoFactory(request).getJobCardDAO(comLocator).findAllByJobSearch(jobSearch);

     request.getSession().setAttribute("listJobCard", listJobCard);

     System.out.println("Exiting doSearch for job | Date: " + new Date());

     return mapping.getInputForward();
}

I have put System.out.prinln(); for logging at the beginning and at the end of this method just to know the flow of threads. And the outcome is synchronised, the method executed one after another. The output is below.

Inside doSearch for job | Date: Sat Jan 28 14:52:39 IST 2017

Exiting doSearch for job | Date: Sat Jan 28 14:52:50 IST 2017

Inside doSearch for job | Date: Sat Jan 28 14:52:50 IST 2017

Exiting doSearch for job | Date: Sat Jan 28 14:53:00 IST 2017

Upvotes: 1

Views: 387

Answers (0)

Related Questions