struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject Re: help with xml syntax of JSP with taglibs
Date Mon, 09 Feb 2004 18:56:47 GMT
Quick try - what about something like this:

<style type="text/css">
  @import url(<c:url value="/css/main.ss">);
</style>

Otherwise, how 'bout using regular JSP syntax for bar.jsp ;-)? Or, if you're
using JSP 2.0, it's pretty easy to do. If none of those work/apply, here's
something goofy for your entertainment:

<jsp:root xmlns:c="http://java.sun.com/jstl/core"
          xmlns:x="http://java.sun.com/jstl/xml"
          xmlns:jsp="http://java.sun.com/JSP/Page"
          version="1.2">
    <jsp:directive.page contentType="text/plain"/>

    <c:set var="xslt">
        <xsl:stylesheet version="1.0"
                        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:output omit-xml-declaration="yes"/>
            <xsl:param name="href"/>
            <!-- identity xform -->
            <xsl:template match="node()|@*">
                <xsl:copy>
                    <xsl:apply-templates select="node()|@*"/>
                </xsl:copy>
            </xsl:template>
            <!-- replace the href attr -->
            <xsl:template match="@href">
                <xsl:attribute name="href">
                  <xsl:value-of select="$href"/>
                </xsl:attribute>
            </xsl:template>
        </xsl:stylesheet>
    </c:set>

    <x:transform xslt="${xslt}">
        <x:param name="href"><c:url value="/css/main.css"/></x:param>
        <link href="" rel="stylesheet" type="text/css"/>
    </x:transform>

</jsp:root>

Obviously, it makes more sense for the stylesheet to be an independent/external
file...

Quoting Larry Meadors <Larry.Meadors@plumcreek.com>:

> can you use the jstl xml tags to do that? I am guessing you can, but
> don't have time now to look it up...
> 
> LArry
> 
> >>> tj.herring@autozone.com 02/05/04 1:57 PM >>>
> Hello...
> 
> I have a file called /foo/bar.jsp.
> 
> The file bar.jsp is an XML syntax JSP.  The file is only being used by a
> 'forward' therefore the URL in the browser window stays the same (for
> example: http://localhost/webapp/index.jsp).
> 
> index.jsp forwards to /foo/bar.jsp like this:
> <jsp:forward page="/foo.bar.jsp"/>
> 
> 
> Bar.jsp requires the use of a CSS that is located in "/css/main.css"
>  I refer to the css in the XML JSP like this:
> <link href="/css/main.css" rel="stylesheet" type="text/css"/>
> 
> The problem is that /css/main.css is not valid!  It does not generate
> the
> proper path!   I have been advised to use this instead:
> <link href="<html:rewrite page='/css/main.ss'>" rel="stylesheet" type
> ="text/css"/>
> 
> The problem is that the this does not work since it is not valid XML.
> 
> Am I missing something here?  How do I refer to a stylesheet in a JSP
> (that
> will only be used by forward's) and maintain the proper paths????
> 
> Does the html or any other taglib do this for me???
> 
> Thanks in advance for the help!
> 
> TJ Herring
> tj.herring@autozone.com

-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Mime
View raw message