This is a quick question but I couldn't find a quick answer. Now I have a servlet BaseServlet, when user request any of the url below:
host
host/
host/BaseServlet
It should always refer to the same servlet and redirect to the homepage.
When I set
@WebServlet({"/BaseServlet", ""})
Only
host/
host/BaseServlet
works
If I set
@WebServlet({"/BaseServlet", "", "/"})
The BaseServlet will be requested constantly in loop ...
Why?
Edit: BaseServlet does a forward to the index.html hid in WEB-INF folder and that's it.
getServletContext().getRequestDispatcher("/WEB-INF/index.html").forward(request,response);
The servlet spec says "A string containing only the / character indicates the "default" servlet of the application." So I want the BaseServlet to be my default. Why it doesn't work?