tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alec Swan <>
Subject Re: Serving CSS files from a certain URL
Date Wed, 05 Jul 2006 16:08:49 GMT
David, the problem is that there is no servlet container or web server running on the local
machine. I need the JSP page to load the CSS page correctly whether it's deployed on tomcat
or not.

David Smith <> wrote: In your Test.jsp, why don't you have something
similar to:

location="${pageContext.request.contextPath}/css/Styles.css" />

I'm of course assuming tomcat 5.x.x and the web.xml file is declared for 
servlet spec 2.4.  This should work whether the running tomcat instance 
is on your local machine or the production server.


Alec Swan wrote:

>Web designers don't run web servers or servlet containers on their machines. (I call their
environment "static"). They just create web pages using Dreamweaver and preview them in different
browsers. So, in my running example Test.jsp would have the following relative link ../../css/Styles.css
in order for it to work in the "static" environment.
>However, this relative link doesn't work when I deploy Test.jsp in Tomcat. Suppose I deploy
my web-app under /testapp context. In this case, Test.jsp would have to link to the css file
through one of the following links:
>../testapp/css/Styles.css or
>Neither of which work in the "static" environment used by web designers.
>I hope this elucidates the problem a little further. So, the question persists, what is
the right way to get links to CSS files to work in static as well as deployed environment?
>Hassan Schroeder  wrote: On 7/4/06, Alec Swan  wrote:
>>I need to reference Styles.css from Test.jsp in such a way that it works in static
as well as in deployed mode. Note that for this to work in the static mode (no web servers
or servlet containers) all paths should be relative. Therefore, when I deploy Test.jsp I want
Tomcat either to handle relative paths correctly or ignore the path altogether and just serve
all CSS file from a certain location (directory or URL).
>>The goal of all this is to maintain only one source tree used by web designers and
Tomcat administrator and avoid changing paths in JSP files during deployment.
>>I would appreciate any feedback on this.
>OK, since you asked :-)  -- this seems a really strange requirement;
>are your "web designers" unable to run a Tomcat instance to work
>But in any case, using relative links to a css file works fine on a test
>page I just did that mirrors your described files. So *exactly* how is
>this not working for you?

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message