tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 46343] New: .tag files: page scope attribute from outer tag is lost in inner tag
Date Thu, 04 Dec 2008 20:29:37 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=46343

           Summary: .tag files: page scope attribute from outer tag is lost
                    in inner tag
           Product: Tomcat 6
           Version: 6.0.18
          Platform: PC
        OS/Version: Windows Server 2003
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Servlet & JSP API
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: wknauf@hg-online.de


Created an attachment (id=22994)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22994)
Sample for the failing Tags

I asked this on the mailing list (Dec. 2nd, same subject), but got no reply. I
think it is a bug, but maybe it is just an error of mine.

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 !", PageContext.PAGE_SCOPE);
%>
Value before doBody: ${test} <br>
<jsp:doBody/>
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"), it tries to display the page scope
attribute from the outer 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"
     pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="tagfiles" tagdir="/WEB-INF/tags" %>
<html>
<head>
</head>
<body>
<tagfiles:outer>
   Value in test.jsp: ${test} <br>
   <tagfiles:inner/>
</tagfiles:outer>
<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);".

Attached is a sample for this (WAR file created by Eclipse 3.4/WTP 3.0,
including sources).
It contains the .tag files and java code version of the tag. Both are called on
"index.jsp", and the coded tag shows the expected behavior.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message