Skip to content

Commit 5ab4381

Browse files
authored
Merge pull request #371 from chadlwilson/fix-rails-jsp-handling
Fix JSP forward/include under Rails 7
2 parents 67e45d3 + d9ce73b commit 5ab4381

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.2.7 (UNRELEASED)
2+
3+
- Fix ability to include and forward to JSPs under Rails (#370)
4+
15
## 1.2.6
26

37
- Add missing block-only signature for debug logging

examples/README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,24 @@ As an executable jar within Jetty:
2828

2929
## Demo routes
3030

31-
| Example | Component | Embedded Route | Deployed War Route |
32-
|---------|-------------------------------|-----------------------------------|------------------------------------------|
33-
| Rails 7 | Status Page | http://localhost:8080/up | http://localhost:8080/rails7/up |
34-
| Rails 7 | Snoop Dump | http://localhost:8080/snoop | http://localhost:8080/rails7/snoop |
35-
| Rails 7 | Embedded JSP (non-functional) | http://localhost:8080/jsp/ | http://localhost:8080/rails7/jsp/ |
36-
| Rails 7 | Simple Form submission | http://localhost:8080/simple_form | http://localhost:8080/rails7/simple_form |
37-
| Rails 7 | Body Posts | http://localhost:8080/body | http://localhost:8080/rails7/body |
38-
| Sinatra | Demo Index | http://localhost:8080/ | http://localhost:8080/sinatra |
39-
| Sinatra | Info | http://localhost:8080/info | http://localhost:8080/sinatra/info |
40-
| Sinatra | Snoop Dump | http://localhost:8080/env | http://localhost:8080/sinatra/env |
41-
| Sinatra | Streaming Demo | http://localhost:8080/stream | http://localhost:8080/sinatra/stream |
42-
| Camping | Demo Index | http://localhost:8080/ | http://localhost:8080/camping |
43-
| Camping | Snoop Dump | http://localhost:8080/snoop | http://localhost:8080/camping/snoop |
31+
| Example | Component | Embedded Route | Deployed War Route |
32+
|---------|------------------------|-------------------------------------|---------------------------------------------|
33+
| Rails 7 | Status Page | http://localhost:8080/up | http://localhost:8080/rails7/up |
34+
| Rails 7 | Snoop Dump | http://localhost:8080/snoop | http://localhost:8080/rails7/snoop |
35+
| Rails 7 | Simple Form submission | http://localhost:8080/simple_form | http://localhost:8080/rails7/simple_form |
36+
| Rails 7 | Body Posts | http://localhost:8080/body | http://localhost:8080/rails7/body |
37+
| Rails 7 | JSP (render) | http://localhost:8080/jsp/ | http://localhost:8080/rails7/jsp/ |
38+
| Rails 7 | JSP (forward to) | http://localhost:8080/jsp-forward/ | http://localhost:8080/rails7/jsp-forward/ |
39+
| Rails 7 | JSP (include) | http://localhost:8080/jsp-include/ | http://localhost:8080/rails7/jsp-include/ |
40+
| Sinatra | Demo Index | http://localhost:8080/ | http://localhost:8080/sinatra |
41+
| Sinatra | Info | http://localhost:8080/info | http://localhost:8080/sinatra/info |
42+
| Sinatra | Snoop Dump | http://localhost:8080/env | http://localhost:8080/sinatra/env |
43+
| Sinatra | JSP (render) | http://localhost:8080/jsp/index.jsp | http://localhost:8080/sinatra/jsp/index.jsp |
44+
| Sinatra | JSP (forward to) | http://localhost:8080/jsp_forward | http://localhost:8080/sinatra/jsp_forward |
45+
| Sinatra | JSP (include) | http://localhost:8080/jsp_include | http://localhost:8080/sinatra/jsp_include |
46+
| Sinatra | Streaming Demo | http://localhost:8080/stream | http://localhost:8080/sinatra/stream |
47+
| Camping | Demo Index | http://localhost:8080/ | http://localhost:8080/camping |
48+
| Camping | Snoop Dump | http://localhost:8080/snoop | http://localhost:8080/camping/snoop |
4449

4550
## Development
4651

src/main/ruby/jruby/rack/rack_ext.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
module JRuby
1818
module Rack
1919
module RackExt
20-
module Request
20+
module RequestHelpers
2121
java_import org.jruby.rack.servlet.ServletRackIncludedResponse
2222

2323
def forward_to(path, params={})
@@ -38,8 +38,18 @@ def render(path, params={})
3838
end
3939
end
4040

41-
::Rack::Request.module_eval do
42-
include ::JRuby::Rack::RackExt::Request
41+
if JRUBY_VERSION >= '9.4'
42+
::Rack::Request::Helpers.module_eval do
43+
include ::JRuby::Rack::RackExt::RequestHelpers
44+
end
45+
else
46+
::Rack::Request.module_eval do
47+
include ::JRuby::Rack::RackExt::RequestHelpers
48+
end
49+
50+
::ActionDispatch::Request.module_eval do
51+
include ::JRuby::Rack::RackExt::RequestHelpers
52+
end if defined?(::ActionDispatch::Request)
4353
end
4454
end
4555
end

src/spec/ruby/jruby/rack/rack_ext_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
require File.expand_path('spec_helper', File.dirname(__FILE__) + '/../..')
99
require 'jruby/rack/rack_ext'
1010

11-
describe Rack::Request do
11+
describe JRuby::Rack::RackExt do
1212
before :each do
1313
@servlet_request = double("servlet_request")
1414
@servlet_response = double("servlet_response")

0 commit comments

Comments
 (0)