Confusing on the page contexts of tag file and its calling page

Hello,

I read somewhere that for a tag file, its page context is different from the page context of the calling page. For example:

if in the tag file (suppose the tag name is sample, prefix is java), I am writing like that:

<%-- set the page scope message with value hello world

the message is not defined as a variable --%>

<c:set var="message" value="hello world" />

then in the calling page, if it is like:

<java:sample>

<%-- no output here--%>

${message}

</java:sample>

we will not get out put as "hello world" since those two have differnet page context.

But what confuses me is that, if I rewrite the sample tag using tag handler, and in its doTag() method, I set the message as the hanlder's page context attribute:

public class Sampletag extends SimpleTagSupport{

public void doTags(){

..

this.getjspContext().setAttribute("message", "hello world");

..

}

}

then, this attribute is VISIBLE to the calling page.

So my understanding is:

for tag file, calling page and tag file use different page contexts

for tag handler, calling page and tag file use same page context

Am I correct?

Thanks!

[1289 byte] By [sunsprintera] at [2007-10-2 18:58:41]
# 1

I found the answer.

If tag file used, Tomcat uses a wrapper to wrap the page context of the calling page. So the page context of the tag file IS different from the calling page. But for tag handler, we are not using the wrapper so the handler page context and the calling page context are the same.

thanks!

sunsprintera at 2007-7-13 20:37:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...