title: Prevent multiple access of servlet in my application
body: <p>given below is the url configured as an autosys job .This calls the servlet given below.Can anyone suggest me how to protect this method "psServiceWrapper.processHRFeed();" being called continously with improper data modification by each time this url is pressed continously say 10 times.I want it to be accessed only one thread at a time.</p>
  
  <p>I know i have to use a synchronized method or block ..am not sure on how to..since am not that familiar with threads.</p>
  
  <pre><code>http://mydomain:11000/dorf/HRDORFScriptServlet?script=hrFeed
  
  
  public class HRDORFScriptServlet extends HttpServlet {
  
  private static final long serialVersionUID = 1L;
  private static final Logger log = Logger.getLogger(HRDORFScriptServlet.class);
  private final String script = "script";
  
  @Override
  protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
      // TODO Auto-generated method stub
      performTask(arg0, arg1);
  }
  
  @Override
  protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
      // TODO Auto-generated method stub
      performTask(arg0, arg1);
  }
  
   /** Execute the servlet.
   * 
   * @param request
   * @param response
   * @throws ServletException
   * @throws IOException
   */
  public void performTask(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException {
  
      DorfUser dorfUser = DorfSessionUtils.getDorfUser(request.getSession());
      HRDorfFeedServiceWrapper psServiceWrapper = new HRDorfFeedServiceWrapper(dorfUser);
      String reqParam = request.getParameter(script);
      if(reqParam.equals("hrFeed")){
      try{
          psServiceWrapper.processHRFeed();           
      }
      catch(ServiceException se){
          log.error("Error While calling HRFeed Service : "+se.getMessage());
      }
      catch(Exception e){
          log.error("Error While calling HRFeed Service : "+e.getMessage());
      }
  
      }
   }
  </code></pre>
  
  <p>}</p>