I've been struggling with the same problem. I read the bug report, but it only adresses part of the problem, the part that doesn't retrieve the session properly. I actually patched the code independently and have discovered another problem, that somehow sessions are either getting lost or mixed up when you do cross context imports in at least one advanced scenario :

1) page Z in context 'a' import a page X from context 'b'
2) page X in context 'b' imports a page Y in context 'a'

in this case, the session that was created when you import page X in context b is the session that's available in page Y in context a.

here's my test case ---

test_page1.jsp ( context '/profile' ) :

   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
   Test of cross context imports :
   <% request.getSession().setAttribute("test_attrib", "12345"); %>
   <% out.println("test_attrib in ( test_page1.jsp ) is " +
   session.getAttribute("test_attrib") ); %><br/>
   <% out.println("session id (  in test_page1.jsp) is : " +
   request.getSession().getId() ); %> <br/>
   <c:import url="/test_other.jsp" context="/" />

test_other.jsp ( context '/' ) :

   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
   <% request.getSession().setAttribute("test_other_attrib", "54321" ); %>
   <% out.println("test attrib ( in test_other.jsp ) is : " +
   request.getSession().getAttribute("test_attrib") ); %><br/>
   <% out.println("test other attrib ( in test_other.jsp) is : " +
   request.getSession().getAttribute("test_other_attrib") ); %><br/>
   <% out.println("session id (  in test_other.jsp) is : " +
   request.getSession().getId() ); %> <br/>
   <c:import url="/test_page2.jsp" context="/profile"/>

test_page2.jsp ( context '/profile' ) :

   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
   <% out.println("test_attrib ( in test_page2.jsp ) is " +
   session.getAttribute("test_attrib") ); %> <br/>
   <% out.println("test other attrib ( in test_page2.jsp) is : " +
   request.getSession().getAttribute("test_other_attrib") ); %> <br/>
   <% out.println("session id (  in test_page2.jsp) is : " +
   request.getSession().getId() ); %> <br/>



The output i get when I hit test_page1.jsp is :


Test of cross context imports : test_attrib in ( test_page1.jsp ) is 12345 session id ( in test_page1.jsp) is : 2796EBFF6C413841B7B2D496D7E8FD3F test attrib ( in test_other.jsp ) is : null test other attrib ( in test_other.jsp) is : 54321 session id ( in test_other.jsp) is : 2796EBFF6C413841B7B2D496D7E8FD3F test_attrib ( in test_page2.jsp ) is null test other attrib ( in test_page2.jsp) is : 54321 session id ( in test_page2.jsp) is : 2796EBFF6C413841B7B2D496D7E8FD3F


The output I get when i hit test_other.jsp is :



test attrib ( in test_other.jsp ) is : null test other attrib ( in test_other.jsp) is : 54321 session id ( in test_other.jsp) is : 55B2068D3011D727DF15068ADAD713E2 test_attrib ( in test_page2.jsp ) is null test other attrib ( in test_page2.jsp) is : null session id ( in test_page2.jsp) is : 55B2068D3011D727DF15068ADAD713E2


the output that i get when i hit test_page2.jsp :


test_attrib ( in test_page2.jsp ) is 12345
test other attrib ( in test_page2.jsp) is : null
session id ( in test_page2.jsp) is : 2796EBFF6C413841B7B2D496D7E8FD3F


Any hints on how to resolve it?



Asim Alp wrote:


If indeed we need to put it on all pages, then yes, it's no problem. We do have a couple perl geniuses on staff :) I'm sure we'll find a way to get around it.

My main concern right now is to to understand the reason of the problem first. I read the bug report, but still can't understand why an extra session prevents our c:imports from working?

Asim

On Mar 2, 2004, at 1:46 PM, Mike Curwen wrote:

If you have a perl genius on staff, he can do ALL pages with a single
command.  Scary stuff, but cool when it works. :)

-----Original Message-----
From: Asim Alp [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 02, 2004 12:33 PM
To: Tomcat Users List
Subject: Re: cross context include


I guess we'll have to find a way of going over the 10,000+ pages. Maybe we can write a small program to automate it. I don't like dirty solutions :) If this is indeed a bug in our software, it should better be fixed.

One last question though.  As much as I know, setting page session to
false only means that there is no need to create an
additional session.
  What's this have to do with c:imports?  Why does an
additional session
prevent our c:imports?

Asim

On Mar 2, 2004, at 1:15 PM, Remy Maucherat wrote:

Asim Alp wrote:

Thank you for your prompt replies.  I just read the bug, and
understood what the problem was.
Now, though, I have another question.  Is there a way of

setting page

session to false at a higher level. For example somewhere

from the

server.xml file? My problem is that we have over 100

websites with

tens of thousands of jsp pages. Every single one of these

JSP pages

rely on these <c:imports...  It's almost impossible for us to
manually go over each one of these jsp pages and add the <%@ page
session="false"%> line to each of them.  Can you think of an an
easier solution to my problem?


Yes, take advantage that this is OSS and patch your Tomcat

;) Or use


the replacement class (put in
server/classes/org/apache/catalina/core).

--
xxxxxxxxxxxxxxxxxxxxxxxxx
Rémy Maucherat
Developer & Consultant
JBoss Group (Europe) SàRL
xxxxxxxxxxxxxxxxxxxxxxxxx


---------------------------------------------------------------------

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
g




Reply via email to