Obtaing jcr session is mentioned in the /libs/foundation/components/forms/actions/store/forward.jsp.
Second case you mentioned requires that you have slingRequest object with you. You get this when /libs/foundation/global.jsp is included in the jsp you use. There are ample cases of this in the source.
then you can use slingRequest.getResourceResolver to obtain the tag manager.
Thanks for your reply Sam!
I'm still having trouble. With the first method, I've written:
final SlingRepository repository = sling.getService(SlingRepository.class);
final Session adminSession = repository.loginAdministrative(null);
TagManager tagManager = JcrTagManagerFactory.getTagManager(adminSession);
But the problem with this is that the getTagManager method isn't static so I can't call it without an instance of a JcrTagManagerFactory
With the second method:
TagManager tagManager = resourceResolver.adaptTo(ResourceResolver.class);
I'm getting a type mismatch - cannot convert from ResourceResolver to TagManager
Use  & for example refer. Please let me know which document you are reffering so that I can place document update request if it is valid.
 TagManager tagMgr = resourceResolver.adaptTo(TagManager.class)
I was looking at these two api pages:
Filled the issue (DOC-3163) to correct those pages.