Does RequestDispatcher(url).forward(req, res) work for servlet mapping /* ?
843842Apr 18 2010 — edited Apr 18 2010In my dynamic web project 'Test', I have a servlet 'SomeServlet' with doGet method as:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("pageUri", request.getRequestURI());
request.getRequestDispatcher( "SomeJSP.jsp" ).forward(
request, response );
}
My web.xml file contains the following mapping:
<servlet>
<description></description>
<display-name>SomeServlet</display-name>
<servlet-name>SomeServlet</servlet-name>
<servlet-class>test.SomeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SomeServlet</servlet-name>
<url-pattern>/SomeServlet</url-pattern>
<url-pattern>/foo/*</url-pattern>
</servlet-mapping>
For client requests http://localhost:8080/Test/ and http://localhost:8080/Test/SomeServer the program works fine displaying the URI on SomeJSP.jsp.
But for the request http://localhost:8080/Test/foo/someValue an infinite loop of exceptions are thrown at the console pointing error towards the line where I've coded RequestDispatcher.
Can someone please tell me what is causing this problem and how do I fix it to continue accepting any client requests with url-pattern as foo/* ? Thanks in advance.