Bug 36637

Summary: [PATCH] <%@page session="false"%> causes exception in <x:set>
Product: Taglibs Reporter: Martin Algesten <puckman>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: Fix to XPathUtil.java that checks if a session is available before getting the attributes.

Description Martin Algesten 2005-09-13 14:52:44 UTC
When using jakarta-taglibs-standard-1.1.2 in JSP pages where I first declare:

<%@page session="false"%>

I get an exception when using

<x:set>

The exception is:

java.lang.IllegalStateException: Cannot access session scope in page that does
not participate in any session
        at
org.apache.jasper.runtime.PageContextImpl.doGetAttributeNamesInScope(PageContextImpl.java:501)
        at
org.apache.jasper.runtime.PageContextImpl.getAttributeNamesInScope(PageContextImpl.java:487)
        at
org.apache.taglibs.standard.tag.common.xml.XPathUtil.getVariableQNames(XPathUtil.java:100)
        at
org.apache.taglibs.standard.tag.common.xml.XPathUtil.fillVarStack(XPathUtil.java:772)
...
 
Looks like XPathUtil always assumes a session is available.

My setup is briefly:

jakarta-tomcat-5

web.xml starts:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">
..


and an example page that causes trouble:

<%@ page session="false" %>

<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/core" %>

<x:parse var="xml">
  <test>blah</test>
</x:parse>

<x:set var="test" select="$xml"/>
Comment 1 Martin Algesten 2005-09-13 14:53:53 UTC
Created attachment 16386 [details]
Fix to XPathUtil.java that checks if a session is available before getting the attributes.
Comment 2 Rahul Akolkar 2005-09-13 16:11:48 UTC

*** This bug has been marked as a duplicate of 35216 ***