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
BedrockMission!

Learn More

View all

Sign in to view all badges

Using request.getParts() in AEM servlet to get multiple files sent via an AJAX POST

Avatar

Avatar
Validate 50
Level 4
Clive_Stewart
Level 4

Likes

13 likes

Total Posts

197 posts

Correct Reply

4 solutions
Top badges earned
Validate 50
Validate 25
Validate 10
Validate 1
Boost 5
View profile

Avatar
Validate 50
Level 4
Clive_Stewart
Level 4

Likes

13 likes

Total Posts

197 posts

Correct Reply

4 solutions
Top badges earned
Validate 50
Validate 25
Validate 10
Validate 1
Boost 5
View profile
Clive_Stewart
Level 4

24-10-2016

Hi,

I am trying to read multiple files as attachments sent by a POST to my AEM servlet. I need to read each file and then pass them on to a call to AWS Api Gateway.

Looking at the API documentation https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/org/apache/sling/api/SlingHttpServletRequ... it says it inherits method getParts() from javax.servlet.http.HttpServletRequest.

In http://docs.oracle.com/javaee/6/tutorial/doc/gmhba.html it says I can use something like

Collection<Part> parts = request.getParts("file");

However in Eclipse runing my project on Maven Aem archetype 10, I cannot access Part unless I use
Collection<javax.servlet.http.Part> parts but the SlingHttpServletRequest object does not have access to getParts();

Am I approaching this incorrectly in AEM?

I have been working with AEM for 2 years now, but I have never had to read Multiple attachments before.

Regards

Clive Stewart

Replies

Avatar

Avatar
Validate 1
Level 2
nvssr90
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Ignite 5
View profile

Avatar
Validate 1
Level 2
nvssr90
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Ignite 5
View profile
nvssr90
Level 2

25-05-2017

Hi Clive,

Any luck on this one..Even I have same requirement,

 

Thanks,

Sai

Avatar

Avatar
Validate 1
Level 8
MC_Stuff
Level 8

Likes

78 likes

Total Posts

467 posts

Correct Reply

158 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 8
MC_Stuff
Level 8

Likes

78 likes

Total Posts

467 posts

Correct Reply

158 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
MC_Stuff
Level 8

25-05-2017

Hi Clive,

Since SlingHttpServletRequest inherts HttpServletRequest you can use getParts().  Are you getting any error Or method not found?

Thanks,

Avatar

Avatar
Level 1
stuarts51930720
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
stuarts51930720
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile
stuarts51930720
Level 1

11-09-2017

I think the problem is the Servlet API version.   The oracle doc starts "Servlet 3.0 supports".  I think the interface that is being pulled in is an earlier version of the Servlet API.  I don't know if the AEM uber jar has Servlet 3.x apis.

The Adobe repo does not have Servlet API 3.0 . Here is the list from the repo (as of today):

```

<metadata modelVersion="1.1.0">

  <groupId>javax.servlet</groupId>

  <artifactId>servlet-api</artifactId>

  <versioning>

   <latest>2.5</latest>

   <release>2.5</release>

   <versions>

   <version>2.3</version>

   <version>2.4</version>

   <version>2.5</version>

   </versions>

   <lastUpdated>20130711152914</lastUpdated>

  </versioning>

</metadata>

```