3 Replies Latest reply on Aug 22, 2010 7:25 PM by Stan Silvert

    Not a valid response [302 Moved Temporarily]

    Panayiotis Karabassis Newbie

      I am getting the above error when running my JSFUnit test. My application does indeed send a redirect. Can I get the client to follow it?

        • 1. Re: Not a valid response [302 Moved Temporarily]
          Stan Silvert Master

          This page shows how to set the WebClient redirectEnabled flag:

          http://community.jboss.org/wiki/JSFSessionAPI

           

          However, I'm pretty sure that following redirects is enabled by default.

           

          Stan

          • 2. Re: Not a valid response [302 Moved Temporarily]
            Panayiotis Karabassis Newbie

            Hi! Many thanks. Perhaps I should start a new thread.

             

            This is my situation.

             

            I am using a servlet filter that uses the FacesContext. This is possible using the methods described (for example) here.

             

            Here is some code:

            public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException
            {           
                 FacesContextBuilder builder = new FacesContextBuilder();

             

                 FacesContext facesContext = builder.getFacesContext(request, response);
                 Application application = facesContext.getApplication();
                 ELContext elContext = facesContext.getELContext();
                 SessionController sessionController = (SessionController) application.getELResolver().getValue(elContext, null, "sessionController");       

             

                 User currentUser = sessionController.getCurrentUser();

             

                 if (currentUser == null)
                 {

             

             

            Based on the value of currentUser I either call chain.doFilter(request, response) or send a redirect.

             

            It seems that as soon as the JSFSession is created doFilter is called. So it's too late to enable redirects.

             

            A solution that comes to mind is setting currentUser before JSFSession is created. To do this I would need to access the JSFUnit FacesContext before creating the JSFSession. Is this possible?

             

            Again, thank you.

             

            Regards,

                 Panayiotis

            • 3. Re: Not a valid response [302 Moved Temporarily]
              Stan Silvert Master

              I don't know enough about your applicaiton to give a good answer.

               

              What is the SessionController?  Where is it getting the current user from?

               

              I don't see why you need a FacesContext to get the current user.  Isn't there another way?

               

              If you are using standard JEE authentication then you can get the remote user from the HttpServletRequest.

               

              Stan