You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jspwiki.apache.org by Brian Burch <br...@PingToo.com> on 2008/12/05 15:48:36 UTC

Re: Displaying images outside the webapp container (SOLVED)

Brian Burch wrote:
> 
> The DefaultServlet logs that it has inserted a leading forward slash, 
> but I now think this is misleading.
> 
> I created two folders side by side. files/pictures/ is a symlink and 
> files/pictures-local/ is a real folder. View source for both image urls 
> is equivalent (both without leading slash), and the DefaultServlet log 
> entries are also equivalent (both with leading slash). The only 
> difference is that the non-symlink image displays while the symlink one 
> does not.
> 
> I think the most likely explanation is that my META-INF/context.xml is 
> applied to the jspWiki webapp, but tomcat is scheduling the 
> DefaultServlet to find the image. If I am right, I will need to apply 
> allowLinking to the DefaultServlet, or possibly the entire tomcat Host.

My deduction was not correct. The DefaultServlet is running in the 
context of the jspWiki webapp, which is why it is able to find and 
deliver the files/pictures-local/ image.

This meant it was not finding the symlinked image because my 
META-INF/context.xml file was being ignored.

I read the tomcat docs again. My Host is configured to auto-deploy its 
webapps. Auto-deployment uses the $CATALINA_HOME/conf/context.xml file 
and so I presume the META-INF/context.xml file is never processed, or is 
too late because the Context is already created.

I added allowLinking="true" to the auto-deploy context and MY SYMLINKED 
IMAGE DISPLAYED!

The only problem is that every other webapp under the same Host will now 
be allowed to follow symlinks, so I need to work out how to restrict the 
permission to only jspWiki.

Once I have sorted out the details, I will transfer this knowledge to 
the wiki for anyone else who wants to do the same thing.

Brian

Re: Displaying images outside the webapp container (SOLVED)

Posted by Brian Burch <br...@PingToo.com>.
Hassan Schroeder wrote:
> 
>> The only problem is that every other webapp under the same Host will 
>> now be allowed to follow symlinks, so I need to work out how to 
>> restrict the permission to only jspWiki.
> 
> ? allowLinking is a Context attribute, not a Host attribute.

Well, sort of... you have to create a context xml file in 
$CATALINA_HOME/conf/[engine-name]/[host-name]/[context-path].xml

I have just added a new section on this topic to the Tomcat FAQ in the wiki.

http://www.jspwiki.org/wiki/Tomcat#section-Tomcat-HowToAccessFilesOutsideTheWebappContainer

I have also put a link to it from the FAQAdministration page.

Regards,

Brian



Re: Displaying images outside the webapp container (SOLVED)

Posted by Hassan Schroeder <ha...@webtuitive.com>.
Brian Burch wrote:

> I added allowLinking="true" to the auto-deploy context and MY SYMLINKED 
> IMAGE DISPLAYED!

Ah, yeah, you should have deleted that file first, so the one from
META-INF would be used (copied over) :-)

> The only problem is that every other webapp under the same Host will now 
> be allowed to follow symlinks, so I need to work out how to restrict the 
> permission to only jspWiki.

? allowLinking is a Context attribute, not a Host attribute.

-- 
Hassan Schroeder ----------------------------- hassan@webtuitive.com
Webtuitive Design ===  (+1) 408-621-3445   === http://webtuitive.com

                           dream.  code.