How to destoy / Invalidate java servlet session


#1

Hello,

I’m trying do invalidate a java servlet session in an application.
The glassfish (v2) server is configured to use container based auth
which allows us to use the REMOTE_USER request variable.
However I’ve not yet figured out how to logout :).

The application is configured to use active_record_store for its
sessions.
The app is running on jruby-1.2.0 and jruby-rack-0.9.4.

I’ve tried to use

java_session = java.servlet_request.getSession( false )
java_session.invalidate if java_session

But it errors out giving me “Invalid number of arguments (1 for 0)”

Removing the argument from the getSession and calling invalidate does
not seem to do anything.

Any help would be appreciated,
Regards,

Andres


#2

On Mon, May 25, 2009 at 7:34 AM, Andres K. removed_email_address@domain.invalid
wrote:

I’ve tried to use

java_session = java.servlet_request.getSession( false )

Can you try just “servlet_request.getSession(false)” here? I’m not
sure what you’re getting with the “java.” bit out front.

java_session.invalidate if java_session

But it errors out giving me “Invalid number of arguments (1 for 0)”

Removing the argument from the getSession and calling invalidate does not
seem to do anything.

Looks like a possible method selection bug to me. Could you try with a
more recent JRuby to verify that it hasn’t been fixed and then file a
bug at http://jira.codehaus.org/browse/JRUBY?

Thanks,
/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

I’ve tried to use

java_session = java.servlet_request.getSession( false )

Can you try just “servlet_request.getSession(false)” here? I’m not
sure what you’re getting with the “java.” bit out front.

The servlet_request variable is not defined in the controller. The
java.servlet_request part comes from the
jruby-rack kenai page. Maybe the java.servlet_request is only available
in middleware?

more recent JRuby to verify that it hasn’t been fixed and then file a
bug at http://jira.codehaus.org/browse/JRUBY?

I’ll give it a go using jruby-1.3-rc1 soon. The strange thing is it
happens with all calls.

java.servlet_request.getSession().getAttribute( key )

gives me the same error.

Regards Andres