title: Difference between request.getServletContext() and getServletContext()
body: <p>I have <code>SampleServlet</code> class, within that I have override the <code>doGet()</code> method as follows</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      String name = request.getParameter("name");
  
      String userid = (String)request.getServletContext().getInitParameter("userid");
  
      out.print("Name = " + name + "&lt;br&gt;");
  
      out.print("User id= " + userid+ "&lt;br&gt;");
  }
  </code></pre>
  
  <p>Within my <code>Web.xml</code> i have added context parameters as follows,</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;userid&lt;/param-name&gt;
      &lt;param-value&gt;ABC12345&lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>I used <code>request.getServletContext().getInitParameter("userid");</code> statement to access that parameter.<code>request.getServletContext().getInitParameter("userid");</code> Its work fine. However is there any difference between <code>getServletContext().getInitParameter("userid");</code> and <code>request.getServletContext().getInitParameter("userid");</code> Both give me same output but I don't have proper idea about these two.  </p>