You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Billy Ng <ev...@hotmail.com> on 2002/09/27 21:40:21 UTC

taglib url problem

The c tag cannot find the xml document if the directory is behind th WEB-INF
directory like:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<c:import url="/WEB-INF/xml/my.xml" var="xml"/>
<c:import url="/WEB-INF/xml/my.xsl" var="xslt"/>
<x:transform xml="${xml}" xslt="${xslt}"/>

, but I change the xml directory to root, it will work

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<c:import url="/xml/my.xml" var="xml"/>
<c:import url="/xml/my.xsl" var="xslt"/>
<x:transform xml="${xml}" xslt="${xslt}"/>

Would anybody please tell me why?

Thanks!

Billy Ng


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: taglib url problem

Posted by Eddie Bush <ek...@swbell.net>.
Not to be rude, but this would be a question for 
taglibs-user@jakarta.apache.org to answer.  You might get lucky and hit 
on someone here that can tell you ... personally, I never put pages 
under WEB-INF - that's one practice I question.  If you really must do 
this, it would seem reasonable to me you could provide an action that 
would "feed" you the file.

My guess (and that's exactly what it is) is that <c:import> is making a 
fresh request for the file - a request which goes through the same 
channels a client requesting the document would go through - and so it 
cannot retrieve it.  Access under WEB-INF is prohibited by the servlet 
specification.  It is acceptable to forward to there though ... if you 
really feel the need ... so fronting the file with an action would be 
the way to go.  (just declare an action that has the XML file as it's 
"parameter" attribute - and make it of type o.a.s.a.ForwardAction - that 
should do the trick).

... in config ...
    <action path="/xmlFeed"
            parameter="/WEB-INF/xmlFeed.xml"
            type="org.apache.struts.actions.ForwardAction">
    <action path="/xsltFeed"
            parameter="/WEB-INF/xsltFeed.xsl"
            type="org.apache.struts.actions.ForwardAction">

... in page ...
<c:import url="/xmlFeed.do" var="xml"/>
<c:import url="/xsltFeed.do" var="xslt"/>

Give that a go.  If it doesn't work ... wait to see if someone here has 
a better suggestion or ask on taglibs-user like I suggested.

Billy Ng wrote:

>The c tag cannot find the xml document if the directory is behind th WEB-INF
>directory like:
>
><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
><%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
><c:import url="/WEB-INF/xml/my.xml" var="xml"/>
><c:import url="/WEB-INF/xml/my.xsl" var="xslt"/>
><x:transform xml="${xml}" xslt="${xslt}"/>
>
>, but I change the xml directory to root, it will work
>
><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
><%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
><c:import url="/xml/my.xml" var="xml"/>
><c:import url="/xml/my.xsl" var="xslt"/>
><x:transform xml="${xml}" xslt="${xslt}"/>
>
>Would anybody please tell me why?
>
>Thanks!
>
>Billy Ng
>

-- 
Eddie Bush




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>