Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Servlet Filter for PDF

jdawyers
Level 2
Level 2

Good Afternoon

I've been trying to setup a filter to check the property of a pdf and then do something based on that property. My only trouble is that the filter runs even if I set the extension to pdf. How would I go about setting the filter to only execute on requests with the pdf extension.

Here is how I am currently setting it:

@Component(service = Filter.class,

property = { "sling.filter.scope=REQUEST",

"service.ranking=-700",

"sling.filter.extensions=pdf",

"sling.filter.methods=GET",

"sling.filter.methods=HEAD"})

Thanks!

1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Seems with Osgi annotation extension property is deprecated or not supported though you can using sling pattern, it works perfectly

e.g.

"sling.filter.pattern=.*\\.pdf$",

View solution in original post

5 Replies
Arun_Patidar
Community Advisor
Community Advisor

Hi,

I think, It should work, which version of AEM are you using?

Apache Sling :: Servlet Filter Support

Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Seems with Osgi annotation extension property is deprecated or not supported though you can using sling pattern, it works perfectly

e.g.

"sling.filter.pattern=.*\\.pdf$",

View solution in original post