Using Java servlet repository does not work in my Jruby on Rails application running on Tomcat

I am trying to use java servlet repository instead of: cookie_store when working in Tomcat. My application works fine with: cookie_store, but when using: java_servlet_store nothing else is saved ...

This seems to work, however, when I store something in the servlet_request.session file, later I cannot get the value again ... It seems that it is not ...

In my session_store.rb:

require 'action_controller/session/java_servlet_store' NameApplication::Application.config.session_store :java_servlet_store 

In my application application_controller.rb:

 servlet_request.session.putValue(PROXYBRIDGEKEY, proxy_bridge) 

seems to work

But later I try to get the value, and I get zero ...

 servlet_request.session.getValue(PROXYBRIDGEKEY) 

Any ideas what the problems might be here?

To make it clear that the value in the session really works (verified). With a new html request, getting the value no longer works. So there should be a problem with getting a cookie, I think ...

+4
source share
2 answers

One thing you could try is to identify your store as:

require 'action_controller / session / java_servlet_store'

NameApplication :: Application.config.session_store: java_servlet_store ,: key => "MyKey"

I am not sure if this is relevant, but it was necessary for: cookie_store. Of course, you need to identify your servlet key in java_servlet_store. This key will be the cookie key sent to the browser for subsequent requests.

Hope this helps.

+1
source

If this does not work for you, be sure to set the java_servlet_store key to "JSESSIONID" to use the standard JVM session.

From there, in Ruby, all you need to do to read and write the session (this will be access to the JVM session object):

session.id
sessions [: yoursessionvariable]

Note. If you did not initialize the session (assign a value to the session variable), the session will be nil (creating session.id undefined) until you do this.

+1
source

All Articles