-
Notifications
You must be signed in to change notification settings - Fork 137
Servlet Integration
- 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 changesrack_request.env['SCRIPT_NAME']
(effectively avoidingservlet_request.getScriptName
)
- thus setting
- all servlet request header names are converted to the rack compatible HTTP_Header_Name format
-
the context is accessible to any application both through the global variable
$servlet_context
and the Rack environment variableenv['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 whilejruby.rack.rack.release
returns info about the currently used Rack version -
JRuby-Rack's "internal" context (wrapper can be accessed using)
env['jruby.rack.context']
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.