tags:

views:

141

answers:

1

I would like to be able to extract the content already written to the JSPWriter in a custom tag (using the new SimpleTagSupport). Then I want to manipulate that content and then write it back out to the JSPWriter.

In my company we are creating a set of custom tags that will encapsulate all html for a page - so we can be assured of correct html output. The tags do a lot more - provide consistent look and feel, proper markup for accessibility under different situations - normal processing and error considerations etc.. We also want the JSP developers to have as little as needed to code on the page. So, common things on every page are incorporated in the custom tag that encapsulates the whole page (called a page tag). So for example, the page banner is in this outermost custom tag. One of the things the page tag outputs is the html title tag. The content, for accessibility reasons, is dynamic and dependent on the processing of the page first. I would like to be able to process the whole page - after which we know the dynamic content needed for the html title attribute - and then create and insert the title tag. However, by this time all of the content has been written the JSPWriter. So, I want to get the content of the writer add in the html title tag and then write it back out.

Is this clearer? Should I explain more?

Can this be done and if so how?

Thanks so much in advance for any help. Jeremy

+1  A: 

You probably want your page tag to extend BodyTagSupport, then retrieve the data written by child elements via the getBodyContent method. There's an example in the JEE5 Tutorial.

McDowell