« Return to Thread: link to stylesheet in jsp doesn't work

Re: link to stylesheet in jsp doesn't work

by dusty :: Rate this Message:

Reply to Author | View in Thread

I think you were using this JSP template as a view for a Struts2 action, hence the mailing list choice.  If that is the case, just remember that the URL is relative to the action and not the path of the dispatched JSP template.


Larry Reed-2 wrote:
Thank you Christian. This has solved the problem.

I'd like to thank Martin Gainty for also helping. The solution Martin proposed (use 'css/pp.css' rather than ../css/pp.css or something similar) did solve the problem for the first access, but return access via 'input' or 'success' results still did not find the file. The solution proposed by Christian (href="<s:url value='css/pp.css'/>") works in all situations.

-- Larry


----- Original Message -----
From: "Christian Benjamin Ries" <christian_benjamin.ries@fh-bielefeld.de>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Monday, July 6, 2009 3:23:12 AM GMT -08:00 US/Canada Pacific
Subject: Re: link to stylesheet in jsp doesn't work

Try this:

<link rel="stylesheet" href="<s:url value='/css/pp.css'/>"


----- Original Message -----
From: Larry Reed <larryreed@comcast.net>
Date: Monday, July 6, 2009 3:08
Subject: link to stylesheet in jsp doesn't work
To: user@struts.apache.org

> I'm having a problem linking to a stylesheet and could use some help.
>
> My project layout in Eclipse is as follows:
>
> pp_base
>     WebContent
>         css
>             pp.css
>         guest
>             GuestWelcome.jsp
>         index.html
>
> in index.html, I have
>
> <html>
>     <head>
>     <link rel="stylesheet" href="css/pp.css"
> type="text/css"/>    </head>
>
>     <body>
>             <h1>One moment please.</h1>
>     </body>
>   
> </html>
>
> in GuestWelcome.jsp, I have
>
> <%@ page contentType="text/html; charset=UTF-8" %>
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <html>
> <head>
>          <link
> rel="stylesheet" href="../css/pp.css" type="text/css" />
> </head>
>
> <body>
>             <h1>Another moment please.</h1>
>
> </body>
>
> </html>
>
> The style sheet is referenced correctly by index.html but is not
> referenced correctly by GuestWelcome.jsp.
>
> However, if I replace the link in GuestWelcome.jsp with
>
>          <style
> type="text/css">         <jsp:include page="../css/pp.css"/>
>          </style>
>
> then the style sheet is included in place, and it works fine.
>
> What am I doing wrong?
>
> Thanx, Larry
>
> -----------------------------------------------------------------
> ----
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

--
Cand.-Ing. (FH) Christian B. Ries
Fachhochschule Bielefeld
University of Applied Sciences
FB3 /  Ingenieurwissenschaften und Mathematik

Fon:     +49 (0) 521 32 73 538
Mobile:  +49 (0) 176 64 64 63 58



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

 « Return to Thread: link to stylesheet in jsp doesn't work