tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexandros Kotsiras" <kotsi...@mediaondemand.com>
Subject RE: Tomcat and CSS
Date Thu, 27 Apr 2000 20:32:45 GMT

   I found the <BASE tag useful in similar cases where i had to output form
my servlet HTML with links to images , Javascript Files or Stylesheets.
You can always give an absolute URL in those links but you can also use the
Base tag as <BASE HREF="http://www.domain.com/" >
That tag tells the browser which is the "BASE" location of the generated
HTML and then your relative links to images, Javascript files and stylesheet
files will work fine.

-----Original Message-----
From: Jonathan Clark [mailto:jgc-home@bigfoot.com]
Sent: Thursday, April 27, 2000 4:06 PM
To: tomcat-user@jakarta.apache.org
Cc: mbutcher1@uswest.net
Subject: RE: Tomcat and CSS


> -----Original Message-----
> From: M Butcher [mailto:mbutcher1@uswest.net]
> Sent: 27 April 2000 03:02
> To: tomcat-user@jakarta.apache.org
> 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 http://yourhost.com/app/servlet/serveme
>
> 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:
>
> http://yourhost.com/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


--------------------------------------------------------------------------
To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
For additional commmands, email: tomcat-user-help@jakarta.apache.org


Mime
View raw message