I am creating a sample application with following code structure and the build structure as mentioned in the attachment. I am facing a strange problem.
Whenever I am typing the direct path of the URL - "http://localhost:7001/loginApp" neither the image nor the style is getting rendered. However when I am using the actual path -"http://localhost:7001/loginApp/jsp/Login.jsp" I am able to view the image in the page and the style sheet is also getting rendered.
Below is the snippet for the web.xml file:
Interstingly when I am clicking on submit I am able to get the stylesheet rendered.
The jsp file snippet is :
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="../style.css" type="text/css"></link>
To Login please provide your Username and Password
Only when I am first hitting the URL I am not able to get the proper page.
Just for info my images and stylesheet is directly under the war file.
You need to build the CSS URL (and images, etc.) by using the context path. In general, I don't recommend using relative URLs, especially when using a framework--use an absolute URL that includes the context path. There are a variety of ways to do this, a simple web search will find all the different ways.
Also, it's much more convenient to just cut-and-paste directory trees rather than posting an image.
Many thanks David and Bear.
I will try your solution. 2 more queries for you:
i) Is the directory structure correct?
ii) Can you please provide a code snippet to give a more clear understanding of your explanation?
iii) Off track query: How do you copy paste the directory structure from Eclipse? I agree with your point that copy pasting directory structure is more convenient. But is there any way to do it easily?