Servlet Filter for PDF | Community
Skip to main content
Level 2
Nov 30, 2018 8:12 PM UTC
Solved

Servlet Filter for PDF

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Dec 3, 2018 2:28 PM UTC

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$",

Arun Patidar

5 replies

jdawyersAuthor
Level 2
Dec 3, 2018 2:47 PM UTC

Works perfectly, thanks!~

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
Dec 3, 2018 2:28 PM UTC

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$",

Translate
Arun Patidar
arunpatidar
New Participant
Dec 3, 2018 2:07 PM UTC

Ok, I'll check this.

Translate
Arun Patidar
jdawyersAuthor
Level 2
Dec 3, 2018 1:39 AM UTC

Hi Arun,

I am using 6.3.

Translate
arunpatidar
New Participant
Dec 1, 2018 7:25 AM UTC

Hi,

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

Apache Sling :: Servlet Filter Support

Translate
Arun Patidar