I have a simple controller that calls forward_to "/foo.jsp", but the forward fails with this message:
--------------
SEVERE: PWC6117: File "/Users/vivek/dev/demo/j12009/myapp/tmp/war/foo.jsp/foo.jsp" not found
--------------
The root cause of this failure is that ServletRackEnvironment.getPathInfo() forces a path-info to be returned for JSP. This breaks servlet spec compliance.
----------
There is an example in the Servlet spec for this, see Section 3.5
("Request Path Elements") of the Servlet 3.0 spec:
TABLE 3-1 ("Example Context Set Up"):
Servlet Mapping Pattern: *.jsp
Servlet: JSPServlet
TABLE 3-2 ("Observed Path Element Behaviour"):
/catalog/help/feedback.jsp
ContextPath: /catalog
ServletPath: /help/feedback.jsp
PathInfo: null
-----------------
Servlet 2.5 sec 3.4 Table 2 has this example as well.
I would expect ServletPath to be equal to /foo.jsp, and PathInfo to be empty.
The following patch on jruby-rack 0.9.4 fixes the issue:
— a/src/main/java/org/jruby/rack/servlet/ServletRackEnvironment.java
+++ b/src/main/java/org/jruby/rack/servlet/ServletRackEnvironment.java
@@ -44,6 +44,9 @@ public class ServletRackEnvironment extends HttpServletRequestWrapper
- @return full path info
*/
@Override public String getPathInfo() {
+ // If it is a JSP then we dont want to manipulate path-info.
+ if(getServletPath().endsWith(".jsp"))
+ return super.getPathInfo();
StringBuffer pathInfo = new StringBuffer("");
if (getServletPath() != null) {
The problem goes a little deeper – JRuby-Rack is using the Rack-semantics-wrapped servlet request instead of the original servlet request. This happened when I refactored to a servlet API-agnostic interface. The solution appears to be to make the servlet request stored in the rack environment be the unwrapped original request.