Am having problems using Resin, JspTestCase and sessions.

I think session handling is flawed using the jsp test case - 

the caller correctly calls getSession(true) to make a session for the
request, and puts it into the implicit objects available in the
ServletTestCase, however, i get nullpointer exceptions when using the
pagecontext and trying to access session scope attributes.

it seems that the PageContext isn't being created properly - it is being
created without a reference to the session associated with the request.

This is due to the following line at the top of the redirector.jsp page:

<%@page import="org.apache.commons.cactus.server.*" session="false" %>

setting session ="false" means the pageContext is created without a
session, thanks to the 
JspFactory.getPageContext( ... ) call, which takes a  "needSession"
parameter.

I have had a look and there doens't seem a nice way to fix this.

The only way I can see is to write a CactusPageContext to extend
PageContext, and make that a wrapper class (facade?) of the PageContext
returned by the JspFactory class. The problem is that the classes
JspFactory and PageContext are abstract classes rather than interfaces
(aaaagghh). This means we can't simply implement the interface and pass
that class around. 

What would have been nice would be to create a JspFactory wrapper class,
so that we could intercept the JspFactory.getPageContext calls and set
the "needSession" flag according to the testcase. Unfortunately because
it is abstract, and because some containers do "evil" casting to their
own internal type, we can't do this. The generated code that Resin
produces casts the JspFactory to it's internal QJspFactory - so we can't
go down this route without having different redirector pages and classes
for each container :(

We can't set the value of session dynamically either as it's not a
rtexprvalue. :(

The only thing i can think of is to extend PageContext, and delegate
calls to either the pageContext returned by the page, or intercept calls
to things like getSession. Although there are bound to be nasty gotchas
I've not thought of there.


Perhaps the simplest thing would be to have a session_redirector.jsp and
a no_session_redirector.jsp?

Jari

--
Jari Worsley
Senior Programmer
Hyperlink Interactive Ltd

Reply via email to