Skip to content

Commit 7766110

Browse files
committed
[fix] Fix JSP forward/inclusion by monkey-patching the "correct" class
This logic has been moved to re-usable helpers a long time back, which Rails and other frameworks rely upon.
1 parent d1d9811 commit 7766110

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Breaking configuration capability changes
3131
- Drop deprecated `jruby.rack.ignore.env` property, replaced long ago by `jruby.runtime.env` and optional `jruby.runtime.env.rubyopt`
3232
- Drop deprecated `jruby.rack.filter.*` properties, replaced long ago by init parameters `addsHtmlToPathInfo` and `verifiesHtmlResource`
3333

34+
## 1.2.7 (UNRELEASED)
35+
36+
- Fix ability to include and forward to JSPs under Rails (#370)
37+
3438
## 1.2.6
3539

3640
- 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: 3 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,8 @@ def render(path, params={})
3838
end
3939
end
4040

41-
::Rack::Request.module_eval do
42-
include ::JRuby::Rack::RackExt::Request
41+
::Rack::Request::Helpers.module_eval do
42+
include ::JRuby::Rack::RackExt::RequestHelpers
4343
end
4444
end
4545
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)