SlingServlet to handle GET requests from multiple extensions | Community
Skip to main content
Level 2
September 27, 2019

SlingServlet to handle GET requests from multiple extensions

  • September 27, 2019
  • 1 reply
  • 5950 views

Hi All,

I'm using AEM6.4 and for a particular case I have a custom sling servlet must address get requests from multiple extensions.

Eg:

Hence, for any GET request from any of the above URLs('/content/rc/*/*.zip' ,etc).

Now, I have the below code snippet which works completely fine for '.pdf' extension but fails for any other extension.

I doubt that if it has to do anything with the way I have defined multiple extensions because as do notice below pdf is the second extension defined, i.e. its ignoring all other extensions.

How can I address this?

Any suggestions/help would be highly appreciated.

arunpatidar26smacdonald2008

Thanks & Regards,

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Theo_Pendle
Level 8
September 27, 2019

Hi,

You say it works fine for .pdf extensions, but could you be more specific about how it is failing for the others?

Are you getting a 404 - Resource not found? Are you getting a 200 but an error during the execution of doGet()? Etc.

Could you also give us an XML sample of the node structure under /content/rc/abs/en/membership/interviews/AESSVID0250 please?

I think I have an idea but need more info

arunpatidar
Community Advisor
Community Advisor
September 27, 2019

Hi,

There is a chance to having another servlet which is being resolved and has the highest ranking.

Can you check your request at http://localhost:4502/system/console/servletresolver

Check which servlet is getting called for zip,xls and ppt extensions.

Arun Patidar
Level 2
October 1, 2019

It seems servlet is not registered for zip, ppt etc

Please check Apache Sling :: Servlets and Scripts

Apache Sling :: Servlets and Scripts


arunpatidar26 Yes, but that means the servlet is registered for one of the extensions but not for others(as .pdf requests are redirected to my custom servlet). I was not sure if that's possible

Also from the list of extensions defined for this servlet, it always only accepts pdf irrespective of its positioning.

eg: extension ={"pdf", "zip","ppt"}  or extensions = {"zip", "pdf", "ppt"}  or extensions = {"zip", "ppt", "pdf"}

Is there any place else where we need to define the list of extensions allowed by a servlet?

or

Is there something wrong with the way I have defined extensions because it does pick .pdf extension?

Regards,