I need a sanity check.
I am implementing templates using custom tags. The custom tag calls pageContext.include() which in turn intantiates the same custom tag.
Here is the scenario, question, and code I realize the fact that
"if a custom tag occurs multiple times on a JSP page, a single instance of the tag handler may be used to handle all of those occurences" In this case, fileA.jsp instantiates the RenderTag (template:render). The nested tag PutTag (template
ut) gets the section/content pairs of values and stores the values in the REQUEST_SCOPE of the pageContext useing pageContext.setAttribute(section,content,PageContext.REQUEST_SCOPE) .
The PutTag doesn't play any more part. Next the doEndTag() of RenderTag instance dynamically includes the file "templateFile.jsp".
This is where I have questions: 1. In the included file the RenderTag is instantiated again. It instantiates a NEW RenderTag object. CORRECT?
2. But since this included file is a NEW jsp file, it has its own NEW pageContext , but calling pageContext.getAttribute(section,REQUEST_SCOPE), should retrieve the ORIGINAL section/content pair that I had stored in the outside files pageContext. I believe this is the case, because the included file did get the SAME request object, and the stored section/content pair of values came with it. CORRECT?
I have tested this and it works. I want to confirm that my understanding of same tag instantiation in included files is correct. And I also want to confirm my understanding that sharing attributes using REQUEST_SCOPE of different pageContexts is a safe way, as long as we are dealing with "included" files in the same request.
realFile.jsp
templateFile.jsp
RenderTag.java
Thank you so much for reading this far.
/hs