Search code examples
imageservletsfilesystemsservlet-filtersdeployment-descriptor

Servlet Filter for URIs in alternatedocroot


Is it possible to apply ServletFilters on content delivered via an alternatedocroot?

Filter mapping

<filter-mapping>
    <filter-name>StaticContentAuthenticationFilter</filter-name>
    <url-pattern>/img/users/*</url-pattern>
</filter-mapping>

Alternate Docroot

<glassfish-web-app>
    <context-root>/xxx</context-root>
    <property name="alternatedocroot_1" value="from=/img/* dir=C:/appdata" />
</glassfish-web-app>

Problem statement:
Do some authentication before serving static content (specifically images). Since I am serving images I cannot use a database nor can I keep the images in the .war file


Solution

  • Sorry! The above code works! There was an error elsewhere in the application.