I have a very simple servlet that should handle requests to the root of my app. It is deployed onto IBM Websphere.
Basically, I want to return index.jsp
each time user requests my app like:
Here is the code:
@WebServlet(urlPatterns = {"", "/"})
public class MainPageController extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.getServletContext().getRequestDispatcher("/index.jsp").forward(req, resp);
}
}
It works as it should (I'm getting the JSP), but when JSP page is returned - JSP requests JS, CSS files and those requests (example http://localhost:8888/myapp/js/main.js) are caught by that servlet.
Why my servlet, which should handle only /
also handles other requests (like /js/main.js
)?
Nothing special in web.xml
. No servlet mappings, no other servlets, no welcome file list declaration.