I tried to set default servlet by this way:
@WebServlet({"/abc", "","/"})
public class GreetingServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
getServletContext().getRequestDispatcher("/asd/ind.html").forward(request,response);
}
@Override
public String getServletInfo() {
return "The Hello servlet says hello.";
}
}
The file /asd/ind.html is exist, when I remove "/" like :
@WebServlet({"/abc", ""})
the redirection works fine when I hit:
contextpath/abc contextpath/ contextpath
But with "/" like
@WebServlet({"/abc", "","/"})
It turns out
javax.servlet.ServletException: AS-WEB-CORE-00089
When I hit any URL at all, even the previous ones that did work.
Could anyone please give me an explanation? the "/" should make the servlet default which means any unmapped URL should redirected to GreetingServlet.