Details
-
Bug
-
Resolution: Done
-
Major
-
None
-
None
Description
When there is a servlet specified like:
<servlet> <servlet-name>index</servlet-name> <jsp-file>/index.jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>index</servlet-name> <url-pattern>/index</url-pattern> </servlet-mapping>
and the backing JSP uses RequestDispatcher#forward pointing to a different JSP file, the JspServlet will unfortunately try to render the first JSP again, resulting in StackOverflowError in most of the time.
When investigating this issue with the debugger by making a sample request to /index, it appeared that JspFileHandler sets the request attribute Constants.JSP_FILE, and that will have the value of the JSP file from the <jsp-file> directive. This is great, until the JSP itself tries to call RequestDispatcher#forward using a path on the servletcontext, such as /hello.jsp. In this scenario, JspFileHandler no longer gets invoked, because simply that JSP isn't bound to a servlet, so the request attribute remain the old value and JspServlet just simply grabs the value from the request attribute again and displays the /index.jsp again, and again, and again.
This looks to be a bug in Jastow, but I'm not really sure how to fix it. I would assume that using dispatcher#forward from a JSP to call an another JSP (even indirectly, i.e. through dispatching the request to a servlet, which then would dispatch the request to a JSP) should be within the bounds of the servlet spec, but let me know if I'm violating the spec with my application in any ways.
Attachments
Issue Links
- is duplicated by
-
WFLY-4690 Include in Jsp cause StackOverflow
- Closed