aspose file tools*
The moose likes JSP and the fly likes JSP with CSS does not display the background image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP with CSS does not display the background image" Watch "JSP with CSS does not display the background image" New topic
Author

JSP with CSS does not display the background image

prakash chauhan
Ranch Hand

Joined: Jun 22, 2007
Posts: 81
Hi All,
i dont understand what am i doing wrong.

I have a jsp file that i am using with a CSS.
My directory structure is like this:

ProjectName
--Web
---IMAGES
----linkhead.jpg
---stylesheets
----homepagestylesheet.css
--home.jsp


in my CSS i have defined the #header id selector as follows:



when i try to open this jsp through Tomcat , it applies the CSS (like the fonts and DIVs however my background images are not showing up) None of the background images are showing up


If i have the same directory structure and i save the jsp file as html(Not through Tomcat) , and open it then the background shows up however openening the same file as html through Tomcat also doesnot show me the background

what am i doing wrong?
I even tried to put the image file directly under the Web folder along with the jsp file and css but still it does the same thing.

-Thanks.
[ November 03, 2007: Message edited by: prakash chauhan ]
prakash chauhan
Ranch Hand

Joined: Jun 22, 2007
Posts: 81
oh i was doing a mistake , its working now..
i placed the IMAGES folder within my Stylesheets folder and now images are showing up.
-Thanks.
Greg Potter
Greenhorn

Joined: May 29, 2011
Posts: 1
I have the similar problem and I don't know how to fix it.

I have the following directory structure



My CSS tries to use an image as a background



and it doesn't work while other parts of css work fine.

Firebug shows that application tries to access image by URL _http://localhost:8080/images/img02.jpg and gets 404 error

When I try to access image directly I also get this error. Also I tried _http://localhost:8080/paygate/images/img02.jpg _http://localhost:8080/paygate/resources/images/img02.jpg ...and this error doesn't stop follow me.

How should I organize my directory structure or what should I do to make my images accessible. Thank's!

P.S. I'm using springsource tc server as a webserver.
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

please note



and




and i am not able to understand why you have putted your style.css in two different location.

Why not make a folder and put all the CSS in it..

One more thing,,

You directory structore shows there is so many error you have in your project.Try to correct all the error before running it.


SCJP6.0,My blog Ranchers from Delhi
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

one more thing try cleaning your complete project and also tomcat server,then run the jsp file
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP with CSS does not display the background image