I'm a bit confused as to what's what in this question: which bits are in the JSP and which are in the tag file?
I think the essence of your question regards the body content of tags implemented by tag files: the answer is any tag implemented as a SimpleTag (including tag files) must not contain JSP scripting elements in their body. So for example, if the <myTagFileExample2:frag /> is a tag file (or SimpleTag) taking a body, then this is invalid:
This will cause a translation error because scripting element(s) are declared in the body. There are two explanations here: SimpleTags use a JspFragment to control the output of their body, but JspFragments (unlike BodyContent) don't push a new JspWriter onto the 'out' stack. It is therefore dangerous to use an expression inside the body of a SimpleTag/tag file because this would be written directly to 'out' and wouldn't be encapsulated in the JspFragment for later invocation. The second reason is that SimpleTag only has the doTag() method of interest, so cannot cause the container to synchronise between scoped attribues in the SimpleTag/tag file and scripting variables in the JSP page... Therefore, scripting variables are useless because they can't be updated by a Simpletag.
You will note however that EL statements are valid in SimpleTag bodies, due to the different way in which they are invoked, and because they only ever reference scoped attributes/EL implicit objects, which are not as 'tied down' to the JspPage implementation as scripting variables are. Synchronisation on scoped attributes is much easier to perform from a tag file (using the JspContext/PageContext or the <c:set> JSTL action).
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )