Forward all requests to a servlet
Hi All,
I am new to web development and need some help from you guys.
My requirements are:
1. When a user types http://localhost:8080/someName, the request should be received by a servlet.
2. This servlet simply forwards the request to a jsp page "template.jsp"
I have the following codes and configuration of the web.xml
//*** Servlet named Dispatcher ************
/*
* Dispatcher.java
*
* Created on October 8, 2006, 8:27 PM
*/
package engine;
import java.io.*;
import java.util.Enumeration;
import javax.servlet.*;
import javax.servlet.http.*;
public class Dispatcher extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
String path="/template.jsp";
RequestDispatcher rd;
rd = request.getRequestDispatcher(path);
rd.forward(request, response);
}
}
//*** The web.xml has the following entry *******
<servlet>
<servlet-name>Dispatcher</servlet-name>
<servlet-class>engine.Dispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
My problem is that when I type http://localhost:8080/someName, it goes in an infinite loop.
Does anyone have a solution for this?
I would appreciate any solution to this problem.
Thank you all.
Sam

