Hi Pedro,

Are you sure your SessionFilter is a real Filter? It looks like you're not
extending the Filter interface. The second problem I can see is that you're
completely bypassing the filter initialization in your init() method (I
think it is safer to call super.init(filterConfig)).

Have you registered the filter as a filter in the web.xml file?

Thanks
-Vincent

> -----Original Message-----
> From: Pedro Nevado [mailto:[EMAIL PROTECTED]
> Sent: mardi 14 septembre 2004 12:56
> To: [EMAIL PROTECTED]
> Subject: FilterRedirector does not initialize sessions. - IS THIS A BUG ??
> 
> Hi there,
> 
> In the Cactus documentation says that the Redirector proxy " creates an
> HTTP
> Session if the user has expressed the wish (using the
> WebRequest.setAutomaticSession(boolean)  code in the beginXXX()  method.By
> default a session is always created) and the redirector fills by
> reflection
> the session implicit object."
> 
> If my understanding of the previous paragraph is correct, the following
> two
> tests should not fail:
> 
> ..........................................................................
> ..
> ...
> 
> public class SessionServlet extends HttpServlet {
> 
> }
> 
> public class SessionServletTest extends ServletTestCase {
> 
>     public void beginSessionNull(WebRequest request) {
>         request.setAutomaticSession(true);
>     }
> 
>     public void testSessionNull() {
>         SessionServlet sessionServlet = new SessionServlet();
>         assertNotNull("There should be a session", session);
>     }
> 
> }
> ..........................................................................
> ..
> ...
> 
> public class SessionFilter {
> 
>     private FilterConfig filterConfig;
> 
>     public SessionFilter() {
>     }
> 
>     public void init(FilterConfig filterConfig) {
>         this.filterConfig = filterConfig;
>     }
> 
>     public void doFilter(ServletRequest req, ServletResponse resp,
> FilterChain filterChain) throws IOException,
>             ServletException {
>     }
> 
>     public void destroy() {
>         this.filterConfig = null;
>     }
> }
> 
> public class SessionFilterTest extends FilterTestCase {
> 
>     public void beginSessionNotNull(WebRequest request) {
>         request.setAutomaticSession(true);
>     }
> 
>     public void testSessionNotNull() throws ServletException, IOException{
>         HttpSession session = request.getSession(false);
>         SessionFilter sessionFilter = new SessionFilter();
>         sessionFilter.init(config);
>         FilterChain mockFilterChain = new FilterChain() {
>             public void doFilter(ServletRequest theRequest,
> ServletResponse
> theResponse) {
>             }
> 
>             public void init(FilterConfig theConfig) {
>             }
> 
>             public void destroy() {
>             }
>         };
>         sessionFilter.doFilter(request, response, mockFilterChain);
>         assertNotNull("There should be a session", session);
>     }
> }
> ..........................................................................
> ..
> ...........................
> 
> Well, the ServletSessionTest is OK, but the SessionFilterTest fails,
> although both of them "have expressed the wish (using the
> WebRequest.setAutomaticSession(boolean)  code in the beginXX    Xmethod.
> 
> Could anybody tell me if I am overlookin something? I would really
> appreciate it.
> Regards,
> 
> Pedro Nevado
> 
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to