Discussion:
[FreeMarker-user] images and relative path
domnic savio
2012-12-08 20:47:20 UTC
Permalink
Hi there,
I am trying to display a logo image on the page that is generated. I am
doing a simple app using java servlets.

I have my ftl und WEB-INF.
my Images are under WEB-INF/images/logo.png

my web.xml has
 <init-param>
            <param-name>TemplatePath</param-name>
            <param-value>/WEB-INF</param-value>
        </init-param>

and in im ftl.. I have something like
<div class="container_12">
  <h2>
<image src="/images/thumb.png"/> Pandora's Box </h2>

I am not able to get my image on the rendered html. Can someone point me
where I am making a mistake.. would be highly appreciated
thanks
Domnic
Daniel Dekany
2012-12-08 23:50:11 UTC
Permalink
Post by domnic savio
Hi there,
I am trying to display a logo image on the page that is generated.
I am doing a simple app using java servlets.
I have my ftl und WEB-INF.
my Images are under WEB-INF/images/logo.png
my web.xml has
<init-param>
<param-name>TemplatePath</param-name>
<param-value>/WEB-INF</param-value>
</init-param>
and in im ftl.. I have something like
<div class="container_12">
<h2>
<image src="/images/thumb.png"/> Pandora's Box </h2>
The WEB-INF folder is not visitable for security reasons; that's the
main point of its existence. Even if it was, you had to write
src="/WEB-INF/images/logo.png". So move the "images" directory one
level higher. See the Servlet specs for more info.

Also, "/images" won't work if the context path (again, see in the
Servlet specs) is not just "/" but something like "/mywebapp".

But all this has nothing to do with FreeMarker really. These are
Servlet questions.
Post by domnic savio
I am not able to get my image on the rendered html. Can someone
point me where I am making a mistake.. would be highly appreciated
thanks
Domnic
--
Best regards,
Daniel Dekany
Loading...