1 Reply Latest reply on May 4, 2007 3:00 PM by Vijay Kumar

    Authenticate and redirect/forward to another page in the por

    Vijay Kumar Newbie

      Hello
      I have a request from a user of my portal to automatically log in the user into the portal and then take them to a particular page say p1.jsp .

      The user will pass a param in the request "next_url=UserManager/UserListPortletWindow?action=2&operation=view_reg_code"

      Since I use a DatabaseLoginModule I am able to to the authenticate the user by having his link point to

      /portal/j_security_check?&j_username=xyz&j_password=y&next_url=above string

      This works fine, the user is logged in, but the user is brought to the home page or default page specified in the web.xml.

      How do I redirect or forward the request to the next_url after successfully authenticating him.

      I tried to put in the following code in the commit() method of the DatabaseLoginModule in a failed attempt to forward the request

      public boolean commit() throws LoginException {
       boolean result = super.commit();
      
       try{
       HttpServletRequest request = (HttpServletRequest) PolicyContext.getContext(REQUEST_CONTEXT);
      
       RequestDispatcher rd = request.getRequestDispatcher("/users");
       HttpServletResponse response = (HttpServletResponse) PolicyContext.getContext("javax.servlet.http.HttpServletResponse");
       rd.forward(request, response);
       } catch (Exception e) {
       log.error("Caught Exception while putting MyRackspaceUser in session!", e);
       }
       return result;
      }
      


      this fails because there is no such context as "javax.servlet.http.HttpServletResponse"

      There does not seem to be a way to redirect the request.

      Is there any way to redirect/forward the user to a specific page in the portal right after login.

      Any help is highly appreciated.
      Thank you so much.

      Vijay