You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2002/11/20 19:25:41 UTC

[tiles] relative paths for the .jsp files

Given the following structure:
/path/to/tomcat/webapps/myApp/three.jsp
/path/to/tomcat/webapps/myApp/four.jsp
/path/to/tomcat/webapps/myApp/WEB-INF/jsp/one.jsp
/path/to/tomcat/webapps/myApp/WEB-INF/jsp/two.jsp
/path/to/tomcat/webapps/myApp/WEB-INF/jsp/header.jsp
/path/to/tomcat/webapps/myApp/WEB-INF/jsp/footer.jsp
/path/to/tomcat/webapps/myApp/WEB-INF/jsp/menu.jsp

When I use classicLayout, all of the "put" calls seem to be relative to the
location of the layout file:

<tiles:insert page="WEB-INF/jsp/classicLayout.jsp" flush="true">
  <tiles:put name="title"  value="My first page" />
  <%-- these are relative to the location of the layout,
       so it's looking in WEB-INF/jsp/    --%>
  <tiles:put name="menu"   value="menu.jsp" />
  <tiles:put name="body"   value="one.jsp" />
  <tiles:put name="header" value="two.jsp" />
  <%-- must back up out of WEB-INF to get other files --%>
  <tiles:put name="footer" value="../../four.jsp" />
</tiles:insert>

However, for vboxLayout, this is not the case:

<tiles:insert page="WEB-INF\jsp\vboxLayout.jsp" flush="true" >
  <tiles:putList name="list" >
    <%-- must specify path relative to the webapp root --%>
    <tiles:add value="WEB-INF\jsp\header.jsp" />
    <tiles:add value="WEB-INF\jsp\aBody.jsp" />
    <tiles:add value="three.jsp" />
    <tiles:add value="four.jsp" />
    <tiles:add value="WEB-INF\jsp\footer.jsp" />
  </tiles:putList>
</tiles:insert>

Also I just noticed that vboxLayout only works with the '\' separator.  If I
switch to '/' it can't seem to find any of the files. :(  This is running
under Tomcat 4.1.14 and the Struts nightly build from the 18th.  

If '/' does not work on Windows, when I move this to HP-UX I suspect that
'\' will stop working.

Is this the expected behavior?  I found it a little confusing as a tiles
newbie.

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

Re: [tiles] relative paths for the .jsp files

Posted by Cedric Dumoulin <ce...@apache.org>.

Wendy Smoak wrote:

>Given the following structure:
>/path/to/tomcat/webapps/myApp/three.jsp
>/path/to/tomcat/webapps/myApp/four.jsp
>/path/to/tomcat/webapps/myApp/WEB-INF/jsp/one.jsp
>/path/to/tomcat/webapps/myApp/WEB-INF/jsp/two.jsp
>/path/to/tomcat/webapps/myApp/WEB-INF/jsp/header.jsp
>/path/to/tomcat/webapps/myApp/WEB-INF/jsp/footer.jsp
>/path/to/tomcat/webapps/myApp/WEB-INF/jsp/menu.jsp
>
>When I use classicLayout, all of the "put" calls seem to be relative to the
>location of the layout file:
>  
>
The "put" call end up with a <tiles:insert attribute="attributeName" /> 
 which internally do an include of the URL associated to the attribute.
If the URL is relative, the include call is relative to the current 
context path, which is generally the layout.

><tiles:insert page="WEB-INF/jsp/classicLayout.jsp" flush="true">
>  <tiles:put name="title"  value="My first page" />
>  <%-- these are relative to the location of the layout,
>       so it's looking in WEB-INF/jsp/    --%>
>  <tiles:put name="menu"   value="menu.jsp" />
>  <tiles:put name="body"   value="one.jsp" />
>  <tiles:put name="header" value="two.jsp" />
>  <%-- must back up out of WEB-INF to get other files --%>
>  <tiles:put name="footer" value="../../four.jsp" />
></tiles:insert>
>
>However, for vboxLayout, this is not the case:
>
><tiles:insert page="WEB-INF\jsp\vboxLayout.jsp" flush="true" >
>  <tiles:putList name="list" >
>    <%-- must specify path relative to the webapp root --%>
>    <tiles:add value="WEB-INF\jsp\header.jsp" />
>    <tiles:add value="WEB-INF\jsp\aBody.jsp" />
>    <tiles:add value="three.jsp" />
>    <tiles:add value="four.jsp" />
>    <tiles:add value="WEB-INF\jsp\footer.jsp" />
>  </tiles:putList>
></tiles:insert>
>  
>
  The "vBoxLayout " call end up with a <tiles:insert 
name="attributeName" /> which internally resolve the name type 
(attribute, definition name, url, string), and then do an insert 
accordingly. In the case of an attributeName, the call falls to the 
previous case (<insert attribute="attributeName"/>). So, both case 
should behave the same. If it is not the case, there is a bug ;-).
  I think that what heppen in your case is that the current context path 
is not the same if you use vBoxLayout or classicLayout.
  Also, using the WEB-INF directory to store pages could lead to strange 
behavior on some web containers. To check if the problem comes from 
Tiles or from the WEB-INF location, you should experiment your previous 
example in a subdirectory not under WEB-INF.

  Personnally I avoid using relative paths with Tiles because it leads 
to some troubles when you reuse the Tiles: you usually don't know what 
will be the current context path, and so, you can't guess your relatives 
path. I advise to use absolute paths (but relative to the webapps), 
starting with a '/'

>Also I just noticed that vboxLayout only works with the '\' separator.  If I
>switch to '/' it can't seem to find any of the files. :(  This is running
>under Tomcat 4.1.14 and the Struts nightly build from the 18th.  
>
  Normally you should be able to use indifferntly "/" or "\". The 
prefferred Java way is "/". Maybe this problem is linked to the fact 
that you try to access pages under "WEB-INF" ?

>
>If '/' does not work on Windows, when I move this to HP-UX I suspect that
>'\' will stop working.
>
>Is this the expected behavior?  I found it a little confusing as a tiles
>newbie.
>
>  
>


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


RE: [tiles] relative paths for the .jsp files

Posted by James Mitchell <jm...@telocity.com>.
Wendy, the source code for Struts-Atlanta does some of what (I think) you
are wanting to do.

Feel free to download it from either

 http://www.open-tools.org/struts-atlanta/downloads (as a zip)

 or

 http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/struts/struts-atlanta/ (cvs
view)




James Mitchell
Software Engineer/Struts Evangelist
http://www.open-tools.org

"If you were plowing a field, which would you rather use? Two strong oxen or
1024 chickens?"
- Seymour Cray (1925-1996), father of supercomputing


> -----Original Message-----
> From: Wendy Smoak [mailto:Wendy.Smoak@asu.edu]
> Sent: Wednesday, November 20, 2002 1:26 PM
> To: 'Struts Users Mailing List'
> Subject: [tiles] relative paths for the .jsp files
>
>
>
> Given the following structure:
> /path/to/tomcat/webapps/myApp/three.jsp
> /path/to/tomcat/webapps/myApp/four.jsp
> /path/to/tomcat/webapps/myApp/WEB-INF/jsp/one.jsp
> /path/to/tomcat/webapps/myApp/WEB-INF/jsp/two.jsp
> /path/to/tomcat/webapps/myApp/WEB-INF/jsp/header.jsp
> /path/to/tomcat/webapps/myApp/WEB-INF/jsp/footer.jsp
> /path/to/tomcat/webapps/myApp/WEB-INF/jsp/menu.jsp
>
> When I use classicLayout, all of the "put" calls seem to be
> relative to the
> location of the layout file:
>
> <tiles:insert page="WEB-INF/jsp/classicLayout.jsp" flush="true">
>   <tiles:put name="title"  value="My first page" />
>   <%-- these are relative to the location of the layout,
>        so it's looking in WEB-INF/jsp/    --%>
>   <tiles:put name="menu"   value="menu.jsp" />
>   <tiles:put name="body"   value="one.jsp" />
>   <tiles:put name="header" value="two.jsp" />
>   <%-- must back up out of WEB-INF to get other files --%>
>   <tiles:put name="footer" value="../../four.jsp" />
> </tiles:insert>
>
> However, for vboxLayout, this is not the case:
>
> <tiles:insert page="WEB-INF\jsp\vboxLayout.jsp" flush="true" >
>   <tiles:putList name="list" >
>     <%-- must specify path relative to the webapp root --%>
>     <tiles:add value="WEB-INF\jsp\header.jsp" />
>     <tiles:add value="WEB-INF\jsp\aBody.jsp" />
>     <tiles:add value="three.jsp" />
>     <tiles:add value="four.jsp" />
>     <tiles:add value="WEB-INF\jsp\footer.jsp" />
>   </tiles:putList>
> </tiles:insert>
>
> Also I just noticed that vboxLayout only works with the '\'
> separator.  If I
> switch to '/' it can't seem to find any of the files. :(  This is running
> under Tomcat 4.1.14 and the Struts nightly build from the 18th.
>
> If '/' does not work on Windows, when I move this to HP-UX I suspect that
> '\' will stop working.
>
> Is this the expected behavior?  I found it a little confusing as a tiles
> newbie.
>
> --
> Wendy Smoak
> Applications Systems Analyst, Sr.
> Arizona State University PA Information Resources Management
>


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