In Java EE web tier, you can inject jpa resources in the objects managed by container, such as servlets, ServletContextListener, JSF beans, and etc.

About the sample code. you can refer to http://java.sun.com/javaee/5/docs/tutorial/doc/bnbrm.html.

Forrest