- Forward from Rails to Servlet/JSP. See
demo_controller.rb
#index
andattributes.jsp
. - Include Rails response in JSP output. See
demo.jsp
. - Arbitrary rendering with servlet response from Rails. See
demo_controller
#not_found
. - Forwarding from servlets to Rails should work fine, but I haven't tried it.
-
-
Save rmanalan/46346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Rails forwarding demo</title> | |
<link href="stylesheets/application.css" media="all" rel="stylesheet" type="text/css" /> | |
</head> | |
<body id="attributes" style="padding:10pt"> | |
<h2>Redmine demo JSP: Request and session attributes</h2> | |
<dl> | |
<dt><tt>servlet_request["hello"] | request.getAttribute("hello")</tt></dt> | |
<dd><%= request.getAttribute("hello") %></dd> | |
<dt><tt>session["rails"] | session.getAttribute("rails")</tt></dt> | |
<dd><%= session.getAttribute("rails") %></dd> | |
</dl> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<%@ taglib uri="urn:org.jruby.rack" prefix="jruby-rack" %> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Rails tag demo</title> | |
<link href="stylesheets/application.css" media="all" rel="stylesheet" type="text/css" /> | |
</head> | |
<body id="demo" style="padding:10pt"> | |
<h2>Redmine demo JSP: Project activity</h2> | |
<jruby-rack:rails path="/projects/activity" params="layout=none"/> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DemoController < ApplicationController | |
def index | |
servlet_request["hello"] = "world!" | |
session["rails"] = "Visible to java!" | |
forward_to "/attributes.jsp" | |
end | |
def not_found | |
render_with_servlet_response do |resp| | |
resp.sendError 404, "Sorry, couldn't find it" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment