tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wolfgang Knauf <>
Subject .tag files: page scope attribute from outer tag is lost in inner tag
Date Tue, 02 Dec 2008 21:14:41 GMT
Hello everybody,

I have a JSP tag file, which sets an attribute to the PageContext. I 
expect this attribute to be present in child tags.

Here is the outer tag (in a file "outer.tag"):

<%@ tag language="java" pageEncoding="ISO-8859-1"%>
<%@ variable name-given="test" scope="NESTED" %>
jspContext.setAttribute ("test", "This is a test !", 
Value before doBody: ${test} <br>
Value after doBody: ${test} <br>

The tag just sets a string "This is a test !" to a page scope attribute 
"test" and calls the tag body.

This is the inner tag (file "inner.tag"):
<%@ tag language="java" pageEncoding="ISO-8859-1"%>
Value in inner tag: ${test} <br/>

My JSP is this:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@ taglib prefix="tagfiles" tagdir="/WEB-INF/tags" %>
   Value in test.jsp: ${test} <br>

The browser shows this:
Value before doBody: This is a test !
Value in test.jsp: This is a test !
Value in inner tag:
Value after doBody: This is a test !

The problem is the empty output in the inner tag. I expect the third 
line to be "Value in inner tag: This is a test !".

If I code this with tag classes, everything works fine: the attribute is 
set through "this.pageContext.setAttribute("test", "This is a test !");" 
and the inner tag finds the value with 
"this.getJspContext().getAttribute("test", PageContext.PAGE_SCOPE);".

Can anybody help? Is such a thing possible with tag files? Or is this a bug?

I can provide a full WAR file if necessary.



To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message