Issue Details (XML | Word | Printable)

Key: JRUBY_RACK-9
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: vivek
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
jruby-rack

forward_to "/foo.jsp" fails on Glassfish v3 preview

Created: 26/May/09 09:30 PM   Updated: 02/Jun/09 12:39 AM   Resolved: 02/Jun/09 12:39 AM
Component/s: None
Affects Version/s: 0.9.4
Fix Version/s: 0.9.5

Time Tracking:
Not Specified

Environment:

I could reproduce on mac os x 10.5.x, on glassfish v3 preview (http://download.java.net/glassfish/v3-preview/promoted/glassfish-v3-preview-b47d.zip), jruby 1.2.0, warbler 0.9.13 (jruby-rack 0.9.4)


Tags:


 Description  « Hide

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) {


Nick Sieger added a comment - 01/Jun/09 11:23 PM

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.


Nick Sieger added a comment - 02/Jun/09 12:39 AM

Fixed in bb907c0.