javatagsjsp-tags

Java Tag update META


I have a basic Java Tag (called PluginTag), which extends TagSupport. This tag adds some behaviour to the calling JSP using the JspWriter instance, e.g.

    this.pageContext.setAttribute("plugins", someBehaviour);

I would like to extend this tag, so that it injects HTML meta data into HEAD of the html document. So as explained, the tag has a JspWriter, and not much else...

Also, by the time PluginTag is invoked, another tag will have written the HEAD and any META data out. The trick is I cant update this tag to do my work - and in any case would like the PluginTag to handle my META data, if possible.

I seen a few things like apache HtmlElement, but dont think they are applicable from the context of a Tag.

Thanks.


Solution

  • It's impossible to access HTML document which is formed outside the custom tag. The reason is that previously formed HTML could have been flushed to the user-agent already while other has not been formed yet.

    Another way to change shipped to the client and rendered HTML document is to use a custom tag which includes some JavaScript that changes the needed HTML-document elements.