Craig wrote:
> You're perfectly free to leave your stylesheet where it is (in the "css"
> subdirectory under your webapp), as long as you use an appropriate
> relative URL:
>  <LINK REL="stylesheet" TYPE="text/css" HREF="../../css/style.css"
TITLE="style" />

This doesn't work.  My version included here in case I missed something:
<LINK rel="stylesheet" type="text/css" href="../../css/style.css" />

This does work (thanks Jeff & Jarnot):
<LINK rel="stylesheet" type="text/css" href="<html-el:rewrite
page='/css/style.css'/>">
It turns into:
<LINK rel="stylesheet" type="text/css" href="/dev/css/style.css">

> NOTE -- the exact same issue will apply to any <img> element in your JSP
> page where you're trying to use a relative URL to an image in the same
> directory.  That fails for the same reason as retrieving the stylesheet
> fails, because the image is retrieved by the client with a separate
> request.

Bingo! This is next problem I ran into.  Again, the ../../ to back up out of
the WEB-INF directory is not working.  No matter what path I put in the
styles that have images (background image, buttons) the client browser
cannot load them.  (I can tell when it sees the stylsheet because of some
bold text and alignment that the styles control.  But no images, ever.)

Images live in:  /dev/images/

I've tried variations of:
body { background: url("../../images/gray.jpg"); }

The only thing that works is hard-coding the context:
body { background: url("/dev/images/gray.jpg"); }

I guess I could put the styles in jsp code and use the rewrite tag!

So for now, I've got:
<style>  <!-- <%@include file="../../css/style.css" %> --> </style>
Which pulls the styles into each page directly.  At least I don't have to
maintain them everywhere, but they do have to go over the wire with every
page view.  I still want to get this to work with an external style sheet,
thinking that the browser will cache it.

Anyway, I know this isn't strictly Struts-related, but I appreciate the
help.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management

Reply via email to