Pierre
Pierre

Reputation: 5156

Glassfish 4.1.1 - alternatedocroot_1

Is it still possible to serve files from an external folder with Glassfish 4 and the alternatedocroot_n property?

In my web.xml file I have :

<context-param>
    <param-name>alternatedocroot_1</param-name>
    <param-value>from=images/* dir=/web/files/</param-value>
</context-param>

And then in an xhtml view I have :

<h:graphicImage name="/images/#{item.filename}"/>

But it returns a 404 error.

Upvotes: 0

Views: 1316

Answers (1)

unwichtich
unwichtich

Reputation: 13857

Yes, it is still possible...

But you have to set it up in the file glassfish-web.xml. Here is an example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
  <property name="alternatedocroot_1" value="from=/images/* dir=/tmp " />
</glassfish-web-app>

This example means, that you should have a folder named images in /tmp and when you access e.g. /images/bla.jpg in your webapp, it should reference /tmp/images/bla.jpg.

Also it doesn't make sense to set the name of the image, you have to set the value:

<h:graphicImage value="/images/#{item.filename}"/>

See also:

Upvotes: 0

Related Questions