3 Replies Latest reply on Apr 24, 2008 12:07 PM by pthorp

    Redirect to another application

    lister

      Hi there,


      I'm hoping that someone can help.  I have 2 seam applications (JBoss 4.3) and currently each has a seperate login screen.  However, I would like to log into one of the apps and, with a hyperlink, call the other application, passing across the Identity to allow me to auto-authenticate on the other side.


      I can successfully call a servlet on the second application using:


      FacesContext.getCurrentInstance().getExternalContext().redirect(url)



      However, I can't figure out how to pass the Identity across and all attempts have resulted in a null object in the servlet.  I've tried doing the following when redirecting to the second app servlet:


      
      String url = "http://myapp/appname/signon.xhtml";
      
      FacesContext context = FacesContext.getCurrentInstance();
      
      HttpServletRequest request =  (HttpServletRequest) context.getExternalContext().getRequest();
      
      request.setAttribute("identity", identity);
      
                          
      
      FacesContext.getCurrentInstance().getExternalContext().setRequest(request);
      
      FacesContext.getCurrentInstance().getExternalContext().redirect(url);
      
      
      



      And then on the servlet I try to retrieve the Identity:


      
      
      HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
      
      Identity identity = (Identity)request.getAttribute("identity");
      
      
      
      



      If anyone can help, I'd be very grateful.  Obviously, if there's a better Seam way of doing this, I'd love to know too.



      Cheers, Lister