The top answer to this question describes a technique to implement an efficient XSLT pipeline in Java:
Efficient XSLT pipeline in Java (or redirecting Results to Sou
The problem is that each TransformerHandler has a separate Transformer associated with it. There's a problem with your 2nd template, but as this is an example I guess that doesn't matter. You want:
//SETTING PARAMETERS HERE
th1.getTransformer().setParameter("foo","this is from param 1");
th2.getTransformer().setParameter("bar","this is from param 2");
Note that you also don't need to create a 3rd transformer you can just start the transform chain on th1.getTransformer()