Obviously, if you don't use Struts tags, then what you want is the
"non-Struts" way to do this, but that's just semantics.

In any case, if you need to prepend the context path, then just get the
context path and do it.  You get this with "request.getContextPath()".
Remember that if you need to use a scriptlet to get part of an attribute
value, the entire attribute value needs to be a scriptlet, not just the
dynamic part.

So, you would do something like this:

<head>
<link href='<%= request.getContextPath() + "/styles.css" %>'
rel="stylesheet">
</head>

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> 
> What is the Struts way to reference a CSS stylesheet
> file and Javascript files such that the web application
> context name will always be prepended to the files so
> that they resolve properly?
> (just like the <html:link page="/mypage.jsp"> construct
>  prepends the context name in the generated page)
> 
> For example, suppose I deploy my webapp under 2 different
> contexts "foo" and "bar" and I have a JSP with tags:
> 
> <head>
> <link href="/styles.css" rel="stylesheet">
> </head>
> 
> and 
> <script language="JavaScript" src="/js/myfunctions.js"
> </script>
> 
> such that, when deploying under context "foo" for example,
> these tags would resolve to:
> 
> <head>
> <link href="/foo/styles.css" rel="stylesheet">
> </head>
> 
> and 
> 
> <script language="JavaScript" src="/foo/js/myfunctions.js"
> </script>
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to