• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CSS Style Looks Different Through JSP In Tomcat - Why?

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Cheers!
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.

All CSS formatting is done by the browser.
The server (Tomcat or otherwise) does nothing but send a stream of text to the client.
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Jason

[ March 09, 2006: Message edited by: Jason Moors ]
[ March 09, 2006: Message edited by: Jason Moors ]
 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do a View Source from the browser to compare the HTML files when sent by a means that works, and wnet sent by a means that doesn't.
 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!?
 
Jason Moors
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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



http://www.w3.org/TR/xhtml1/

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.

You could try validating the xhtml at

http://validator.w3.org/

or you could try changing from Strict to Transitional

XHTML 1.0 Transitional
[ March 09, 2006: Message edited by: Jason Moors ]
 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jason,

THanks for the link. I am trying to adhere to XHTML strict. I think i am including an XML declration though through my HTML tag of:

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

Perhaps the contradictory lines were to blame.

Thanks for all the help, got there in the end
 
It's exactly the same and completely different as this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic