I am getting this error:
HTTP Status 500
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.
And here is my servlet code:
String url = "/panel.jsp";
RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);
How is this caused and how can I solve it?
The forward is forwarding back to the very same servlet again, resulting in an infinite forward loop.
To solve this problem, either make the servlet’s URL pattern more specific so that it doesn’t listen on the forwarded URL
/panel.jsp, or put some attribute in the request scope and check for that before performing the business logic and the forward. The first solution is more recommendable.