You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Karol Bucek edited this page Sep 6, 2025
·
3 revisions
Request
request attributes set on the Servlet request are passed through to the Rack environment
setting request attributes is prior to setting the rack built-in environment variables
thus setting servlet_request['SCRIPT_NAME'] = '/home' before the request is handled by JRuby-Rack changes rack_request.env['SCRIPT_NAME'] (effectively avoiding servlet_request.getScriptName)
all servlet request header names are converted to the rack compatible HTTP_Header_Name format
Rack Environment
the context is accessible to any application both through the global variable $servlet_context and the Rack environment variable env['java.servlet_context']
the underlying Servlet request object is available in the Rack environment via the java.servlet_request key
similarly, the native response object is available via the java.servlet_response environment Hash key
request.env['jruby.rack.version'] returns the JRuby-Rack version
JRuby-Rack's "internal" context (wrapper can be accessed using) env['jruby.rack.context']
Servlet Sessions
A Rack compatible JavaServletStore is provided which can be used as an alternative session store.
All session attributes with String keys and String, Numeric, boolean or (java) object values are automatically copied to the Servlet session. Please note that the Servlet session is created on demand (unless your server documentation states otherwise), thus similar to how Rack/Rails works if you do not touch any session[] data it won't be accessed.