title: Is it thread safety, if I pass my HttpServletRequest, HttpServletResponse, HttpSession objects in Util methods?
body: <p>Suppose I have one repeated task which is going to process <a href="http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpSession.html" rel="nofollow">HttpSession</a> or <a href="http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html" rel="nofollow">HttpServletRequest</a> or <a href="http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletResponse.html" rel="nofollow">HttpServletResponse</a> object. This processing may be abstract some data from HttpSession or set/get some attributes in HttpServletRequest/HttpServletResponse. </p>
  
  <p>Here I am giving one example for idea. I want my current logged in UserId from session. for that I am making one Util method in one of Util classes.</p>
  
  <pre><code>public static Integer getCurrentLoggedInUserId(HttpSession session)
  {
      // here I will process session object and get first User object and
      //after that I will get id from that User Object. This is one repeated task in my app.
  }
  </code></pre>
  
  <p>second example for download file.</p>
  
  <pre><code>public static void downloadFile(HttpSrvletResponse response)
  {
      // here I will set some attribues/parameters in response for download file.
  }
  </code></pre>
  
  <p>Now my question is it thread safety to doing this? I mean is it recommended to pass session/request/response objects from controller/servlets to Util classes? If not, what is solution for these kind of repeated  tasks?</p>
  
  <p>Thanks in advance.</p>