Opened 13 years ago

Closed 13 years ago

#1318 closed defect (fixed)

Extension servlets can't use 'forward' to continue processing a request on a jsp page

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
Priority: minor Milestone: BASE 2.12.1
Component: web Version:
Keywords: Cc:

Description

The regular procedure for a servlet to forward the processing to another JSP or servlet is to use:

request.getRequestDispatcher("forward-to.jsp")
  .forward.forward(request, response);

This works fine in a regular servlet, but not in a servlet that is part of an extension. The result is a '404 File not found' error message. Yet, if the URL that is displayed in the error message is typed manually into a brower the page is displayed as expected.

After some investigation it seems like the cause of the problem is in the net.sf.basedb.clients.web.extensions.RequestWrapper class which is used to wrap a request to an extension servlet in a way that makes various paths logical when seen from the code in the extension servlet. However, it seems like during a 'forward' action, Tomcat changes some internal state in the original request that we are wrapping including the return value of 'getServletPath()'. Out wrapper always return the path to the extension servlet that is currently processing the request, but it seems like Tomcat expects this method to return the path to the JSP page that we are forwarding the request to. The fix is to check if the wrapped request 'getServletPath()' returns different paths at different times. If the path has changed, we must return that one instead of the logical servlet path.

Change History (2)

comment:1 Changed 13 years ago by Nicklas Nordborg

Owner: changed from everyone to Nicklas Nordborg
Status: newassigned

comment:2 Changed 13 years ago by Nicklas Nordborg

Resolution: fixed
Status: assignedclosed

(In [4957]) Fixes #1318: Extension servlets can't use 'forward' to continue processing a request on a jsp page

Note: See TracTickets for help on using tickets.