On Tue, 9 Apr 2002, Jeffrey Bonevich wrote:
> Date: Tue, 09 Apr 2002 09:57:45 -0400
> From: Jeffrey Bonevich <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED]
> To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> Subject: Altering content of BodyContent prior to JSP eval
>
> How can I get at the content of BodyContent in a BodyTagSupport
> subclass, alter that content, and then reinsert the content into the
> body before it gets evaluated as JSP? Is this just just totally
> anathema to JSP spec or something? Say that I have the following:
>
> <mytaglib:bodymunger value="lookup">
> Place the stuff *** here
> </mytaglib:bodymunger>
>
> Then in the BodymungerTag (extends BodyTagSupport) I want to lookup the
> value of "lookup", grab the body content, and replace the string "***"
> with that value. Say the value actually returns a string:
> <mytaglib:othertag/>
>
> Then I want that new content evaluated as JSP.
>
> Is there any way to do this? Do I have to do it manually using Jspc or
> something?
>
This isn't supported by JSP 1.1 or 1.2. Your only choices for body
content are:
- Ignore it
- Treat it as opaque text (i.e. an SQL tag might read a
SELECT statement directly out of the body)
- Execute it as normal JSP text.
In JSP 1.3 (the spec currently being developed), we're considering a
concept called "JSP Fragments" which essentially says "here is a chunk of
JSP code -- treat it as a reusable component" that will be useful for
scenarios like what you are describing. Essentially, you will be able to
use JSP code to create what amounts to a custom tag. However, that
feature is still in the future.
> jeff
Craig
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>