Folks,
I'm totally bumfuzzled. I wrote a sort of cache class that maintains an
ArrayList as part of its instance data. A servlet fills an instance of the
class with data and puts it into the caller's session. The target JSP page
is loaded by the servlet (via sendRedirect()) and grabs the cache instance
from the session and uses it as the source of data for display. This all
works fine.
The cache class has an integer that points to the "current row" in the
ArrayList. Simple stuff, and it almost works as advertised; moveFirst(),
moveLast(), moveAbsolute(n), and next() and previous() work just fine when I
iterate and output all the cached items on the SAME page.
The problem comes when I call cache.next() or cache.previous()--the only two
relative calls--on a page, and then call ANOTHER page which also calls
cache.next(). It is as if the cache object's internal current row pointer is
reset to zero. Or perhaps the second page is working with a different copy
of the object?
I know this much:
1. The session ID is the same on each page, so they are accessing the same
session variables. You'd think session.getValue("RSCache") would return a
reference to the same object.
2. cache.next() works when you iterate through all the items in the cache
and put them all on the same page.
3. I tried putting the cache object back into the session after calling
cache.next(), but it did not seem to make a difference.
4. I have turned off page caching with:
response.setHeader ("Cache-Control", "must-revalidate");
response.setHeader ("Pragma", "no-cache");
Page caching seemed to have no effect on this issue, whether on or off.
5. The cache.next() method works as you would expect when referenced from an
application. I don't understand why passing the reference between two JSP
pages would change anything.
Thanks in advance for... Help? Ideas? Shots in the dark? At this point I'll
take whatever I can get. :-)
== Ross ==
Ross W. Lambert, CTO
WebWolves, LLC
voice: (509) 886-2049
e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
web: www.webwolves.com <http://www.webwolves.com>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets