Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Does RequestDispatcher(url).forward(req, res) work for servlet mapping /* ?

843842Apr 18 2010 — edited Apr 18 2010
In 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 16 2010
Added on Apr 18 2010
1 comment
755 views