title: Include action, Include Directive and hash codes of the request objects?
body: <p>So here is the little code I have:</p>
  
  <p>index.jsp:</p>
  
  <pre><code>Hashcode of request object in main page: &lt;%= request.hashCode() %&gt;
  &lt;%@ include file="includedirective.jsp"%&gt;
  &lt;jsp:include page="includeaction.jsp" /&gt;
  </code></pre>
  
  <p>includeDirective.jsp:</p>
  
  <pre><code>Hashcode of request object in include directive: &lt;%= request.hashCode() %&gt;
  </code></pre>
  
  <p>includeAction.jsp:</p>
  
  <pre><code>Hashcode of request object in include action: &lt;%= request.hashCode() %&gt;
  </code></pre>
  
  <p>So after 3 refreshes on the page, the output:</p>
  
  <pre><code>Hashcode of request object in main page: 1646052972
  Hashcode of request object in include directive: 1646052972
  Hashcode of request object in include action: 318408832
  
  Hashcode of request object in main page: 1646052972
  Hashcode of request object in include directive: 1646052972
  Hashcode of request object in include action: 618720209
  
  Hashcode of request object in main page: 1646052972
  Hashcode of request object in include directive: 1646052972
  Hashcode of request object in include action: 412698049
  </code></pre>
  
  <p>Here are my following questions:</p>
  
  <p>1) Why the hash code of the request object in index.jsp is not changing with every refresh? Should not a new request object be created with every request?</p>
  
  <p>2) Why the hash code of the request object in include action is changing every time I refresh the page? </p>
  
  <p>3) I understand that there are 2 different request objects when I include the page using the action.. If I add this in includeAction.jsp: </p>
  
  <pre><code>&lt;%
  request.setAttribute("actionAttribute", "Attribute set in includeAction");
  %&gt;
  </code></pre>
  
  <p>And then in index.jsp I try: </p>
  
  <pre><code>&lt;%
      out.print(request.getAttribute("actionAttribute"));
  %&gt;
  </code></pre>
  
  <p>I am expecting <strong>NOT TO</strong> see the value of "actionAttribute" but it is there? How come? </p>