Hi everybody. I've created a JSP page that is styled by a CSS sytlesheet. This had been looking just perfect until i needed to run my application through Tomcat. Although the stylsheet is being found, some elements have stopped working. The fonts seem ok, as are all the colors and bording. However, the margins and i suspect padding has just gone awol. When before the page was nicely centered in the middle using the jello design, its now back over to the left and looking all out of sync. Could these problems be caused at all because Tomcat on its own is just a JSP/Servlet container and doesn't support certain style elements like a dedicated html server? Any advice or comments would be greatly appreciated.
The web browser renders the CSS not the servlet container.
When you say that it looked perfect before running on tomcat, do you mean your were running on a different web server or it was a static html page?
Most rendering problems (in particular padding) is due to syntax errors like and missing closed tag. A lot of browser handle invalid syntax but generate unpredictable results.
I would recommend checking/validating the generated html. I can't see it being a tomcat problem.
It might also be worth checking that you can access the CSS files from the browser by entering the URL in the browser. Is all your CSS is one file?
[ March 09, 2006: Message edited by: Jason Moors ] [ March 09, 2006: Message edited by: Jason Moors ]
Joined: Jun 07, 2005
Hi Ben, yes what you are saying makes sense. I've just been playing again and realise that actually.....if i run the site in mozilla through Tomcat it looks ok. Its only when i run the site through IE its goes funny. Why only when through Tomcat though? Does IE somehow read the page differently?
Hi guys, thanks for the amazing quick advice. I've solved the problem by removing my top line:
<?xml version="1.0" encoding="UTF-8"?>
Eveything "seems" to be working fine without this at the moment. I'm not sure why i've got that line there....its something i was taught to always include the last time i built a JSP site about 2 years ago at university.
I have this line at the top:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.strict1-strict.dtd">
which obviously is telling the browser i'm using xhtml. This seems pretty obvious why it wasn't working....but just to confirm, that line i've removed...what was it for....and more importantly will i possibly need it further down the track!?
Joined: Dec 04, 2001
It seems from the WC3 website that you don't need the line, but it is encouraged.
An XML declaration is not required in all XML documents; however XHTML document authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16 and no encoding was determined by a higher-level protocol
Not sure why the line defining that it's an xml file is causing the problem and I'm not an expert on xhtml, but I noticed that you are using the XHTML 1.0 Strict version, so I'm wondering if all your xhtml tags conform to the DTD.
My understanding is that xhtml is not as forgiving as html, therefore you always need an end tag. i.e in html you don't need a closing </br> but in xhtml you must adhere to the xml format and every tag must have an end tag.