title: How to retrieve session value from one servlet to another servlet?
body: <p>In one servlet I have four variables. I want all those four variables to be retrieved to another servlet.</p>
  
  <p>I used the code in servlet 1 as follows.</p>
  
  <pre><code>import javax.servlet.http.HttpSession;
  
  
  session.setAttribute("id",id);
  </code></pre>
  
  <p>In the other servlet I tried to get the value by using the code..</p>
  
  <pre><code>String id = HttpSession.getAttribute("id").toString();
  </code></pre>
  
  <p>I think there is a clear way to do the tracking of the session variables.</p>
  
  <p>I have seen in net but all are confusing to me..</p>
  
  <p>Please help me..</p>