CSS fails to apply for the home page in <welcome-file-list>

337 Views Asked by At

Hello, I have a home page LoginPage.html in /WebContent/html/LoginPage.html

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type"
    content="text/html; charset=windows-1256">
<title>Login Page</title>
<link rel="stylesheet" type="text/css" href="../css/jsStyle.css" />
</head>
<body>...</body>
</html>

I have configured the same in web.xml

</welcome-file-list>
    <welcome-file>/html/LoginPage.html</welcome-file>
</welcome-file-list>

Problem: When I am trying to access the file from the home page URL
http://localhost:8080/Project/
It fails to apply the CSS.
Whereas when I access through the location specific URL
http://localhost:8080/Project/html/LoginPage.html
CSS is applied.

Hence, CSS fails to apply while loading the welcome page; I tried multiple alternatives. Kindly help.

2

There are 2 best solutions below

9
Ramesh On

Your css file location has to be relative to the html file.I think currently you have your css file inside projects folder. If you want to access the css when you are using http://localhost:8080/Project/ your css path has to be css/jsStyle.css. If it doesn't work please update your folder tree structure.

0
Janjo Jose On

I found the solution to the problem.
The Home page must be in the root folder. /WebContent
I made CSS references changes accordingly.

Thank you, JJ