« Return to Thread: Sharing Session information between Rails (Jruby) and Java code in Tomcat/JBoss

Re: Sharing Session information between Rails (Jruby) and Java code in Tomcat/JBoss

by Robert Egglestone :: Rate this Message:

Reply to Author | View in Thread

Hi Brian,

When a container does authentication, the user name is usually passed
using request.getRemoteUser to servlets.
We make this available to Ruby on Rails as @request.env['REMOTE_USER'],
in the same way that Apache does.

If you need direct access to the session, you could use
$java_servlet_request to get the servlet request.

Cheers,
Robert

Brian Anderson wrote:

> Our project had a requirement that we run our Ruby application in the
> same context as our Java application so that we can share
> authentication data. We wanted to be able to have our users log in
> once and then seamlessly hop between the Rails app and the Java app.
> In order to read the java session (and check if they are logged in) we
> had to do the following:
>
> request.instance_variable_get("@session_options_with_string_keys")['java_request'].getSession(true).getAttribute('sessionBean')
>
> We discovered this after we read the blog post at:
> http://twentyseveneighteen.org/2007/11/27/jrubyonrails-on-ibm-websphere-application-server-using-ibm-db2/.
> Ours is slightly different because we were using Tomcat.
>
> Anyway, so what I am curious is:
> Does anyone else have this need/problem to share session data? Is
> there a less tricky way of doing this?
>
> -Brian
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>  

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

 « Return to Thread: Sharing Session information between Rails (Jruby) and Java code in Tomcat/JBoss