css, js, jpg, etc in Java Web App are all seen as text/html type.
for example if I put in the url:
domain.com:8080/Application/css/bootstrap.min.css
it loads as text
Content-Type: text/html;charset=UTF-8
The Java web app is fine in local, but when I upload it to the production server the problem occurs.
So in local is fine:
localhost:8080/Application/css/bootstrap.min.css
Content-Type: text/css;charset=UTF-8
Everything was fine for years until a couple of days ago.
ok, I found the problem. Basically in my SecurityFilter.java class, which I set on my web.xml file with the parameter, I was explicitly declaring the ContentType to text/html for all content. I have now deleted the line and everything is seen by the browser in the right MIME type.
public class SecurityFilter implements Filter {
@Override
public void doFilter(...) throws ServletException, IOException {
...
response.setContentType("text/html; charset=UTF-8");
...
}
}
The strange thing is that I had this line in my code for years and never caused a problem. I still have no idea what happened in the last few days that caused it to create a problem. If someone has the answer I will sleep better at night knowing the reason.