title: servlet response time is slow for first request
body: <p><code>Servlet</code> response time slow only for 1st request</p>
  
  <p><strong>Response time</strong> </p>
  
  <p>1st <code>request</code> is 10.5 seconds.</p>
  
  <p>further <code>request</code> 2.5 seconds.</p>
  
  <p>From few <code>java</code> resources i got to know that the <code>servlet</code> loads the required <code>classes</code> for the first time during the first <code>request</code> and reuses the same for further <code>requests</code> and hence the <code>delay</code></p>
  
  <p><strong>Fix 1:</strong> 
  I created a <code>dummy request</code> within the <code>servlet</code> immediately after the execution of <code>init()</code> method.</p>
  
  <p>Response time : 2.5 seconds for all requests through user agents.</p>
  
  <p><strong>Fix 2:</strong>
  I tried loading possible <code>classes</code> in the <code>startup</code> of <code>servlet</code> </p>
  
  <p>Response time : for first <code>request</code> is 6 seconds. 2.5 seconds for other requests. </p>
  
  <p>Is there are any other possibility of achieving the same because i believe that <strong>method 1</strong> needs code change when there is a change in the url of the application (port number, resource path, etc) and response time of <strong>method 2</strong> is not sufficient.</p>
  
  <p>I have already set <code>loadOnStartup=1</code> for my <code>servlet</code>.</p>