I\'m trying to make a simple Servlets + JSP project. It\'s structure looks like this:
There are two problems in your app:
In JSP, you should use ${pageContext.request.contextPath}
to append the base path for your URLs. With this, you can be sure you will use absolute path instead of relative path for your URLs. So, this:
<link rel="stylesheet" type="text/css" href="../css/style.css"/>
Will be
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css"/>
This can also be accomplished by using <c:url>
from JSTL:
<link rel="stylesheet" type="text/css" href="<c:url value='/css/style.css' />"/>
Your servlet is mapping to every request made in your app. Note that this includes simple requests for resources like this CSS file. If you're not handling these requests successfully, you may get an error response or an empty response or whatever, depends on how you handle the request for CSS files in the servlet. I recommend you to change the URL pattern for your servlet to map to specific paths instead.
<servlet-mapping>
<servlet-name>IndexServlet</servlet-name>
<url-pattern>/index</url-pattern>
</servlet-mapping>