title: Best practice to get EntityManger and UserTransaction from JSP
body: <p>I am currently trying to figure out the best way to get a entity manager and a usertransaction in my application.</p>
  
  <p>In JBoss 5.1 I was able to inject it directly into the JSP file, but this is not permitted anymore:</p>
  
  <pre><code>&lt;%!@PersistenceContext(unitName = "unitname")
      public EntityManager em;
  
      @Resource
      UserTransaction utx;
  %&gt;
  </code></pre>
  
  <p>I have to access <code>em</code> and <code>utx</code> from different locations in my application such as Servlets and Controller classes. So it would be great to have it in one place and to access it globally, but I did not figure out yet how to do it. Any hint would be appreciated.</p>