Reputation: 1337
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.
Upvotes: 0
Views: 803
Reputation: 1337
The problem happened because the default servlet maps the URI to the static path if it's not mapped to any servlet, but what I did is redefining the default servlet, so when I redirect to /asd/ind.html and this URI is not mapped to any servlet the default serlvet is called and in this case the default one is GreetingServlet, this causes infinite loop.
Upvotes: 1