tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Clark" <>
Subject RE: Tomcat and CSS
Date Thu, 27 Apr 2000 20:06:04 GMT
> -----Original Message-----
> From: M Butcher []
> Sent: 27 April 2000 03:02
> To:
> Subject: Re: Tomcat and CSS
> Style sheets are not interpreted by the Java code at all. 
> They are interpreted by the browser (same goes for images, et al).

True indeed.
> Say the servlet resides at
> The client gets back the snippet of code from your original 
> message. It "backs up" two
> directories, and then makes a new request for the page info.css:
> The browser does not have permissions to read the src dir 
> (and it should stay that way).

Good point.

> You probably ought to put the css somewhere else.

Though if you want to bundle the application up into a single jar/war,
it makes sense to include both the HTML and CSS files.  Where could I
put the CSS so that it would be available under the deployment space?
The alternative is to have it elsewhere on the server machine, and
needing to pass extra parameters to say where it is.  This doesn't
sound like an elegant solution.

> Keep in mind that if you can't type in the URL directly to 
> the style sheet from your
> browser (via http or https, not file), then the browser won't 
> be able to load it when it renders the HTML page, either.

Well, this is the odd thing.  The CSS file is readable this way.
The _really_ odd thing is that the setup I quoted did work for one
programming session. And then without making any changes it wasn't
working at the beginning of my next session, and has remained broken
ever since.  This has puzzled me completely!

Any more thoughts?

Thanks for your help so far,

Jonathan Clark
> Jonathan Clark wrote:
> > Hi all,
> >
> > I have a problem working with CSS in Tomcat.
> > (I've checked the archives and can't find anything on this 
> subject...)
> >
> > In my servlet ("Info"), I refer to an external CSS file as follows:
> >
> >         out.println("<html><head>");
> >         out.println("<title>Testing Info Servlet</title>");
> >         out.println("<LINK REL=StyleSheet 
> HREF=\"../../info.css\" TYPE=\"text/css\"
> > MEDIA=screen>");
> >         out.println("</head><body>");
> >         ...
> >
> > I'm following the suggseted directory layout. So I put a 
> the info.css
> > file in the servlet's src\ directory.  This gets mapped to the
> > tomcat\webapps\Info\ directory as it should do.  The servlet's class
> > files lands up in tomcat\webapps\Info\Web-inf\classes also as you'd
> > expect.
> >
> > But it doesn't read the CSS file.
> > If I save a copy of the generated HTML, and set that up two levels
> > down a directory tree from the info.css file, then it all 
> works perfectly.
> >
> > HAs anyone any ideas on what I could be doing wrong?
> >
> > Cheers,
> >
> > Jonathan Clark

View raw message