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

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments
SOLVED

for doPost servlet, SlingHttpServletRequest getting empty

Avatar

Level 4

From Dam, I have uploaded a html and js files, For that dam js, I am posting the formdata to servelt using ajax call, the request will entered into the dopost method but request parameter are getting empty.

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hello everyone.

Thank you for taking the time to respond. I noticed an unusual behaviour: when we print in the logger.info, we get an empty text, while the same data is populating in the payload.

 Quite strange behaviour😅

 

 

 

View solution in original post

5 Replies

Avatar

Correct answer by
Level 4

Hello everyone.

Thank you for taking the time to respond. I noticed an unusual behaviour: when we print in the logger.info, we get an empty text, while the same data is populating in the payload.

 Quite strange behaviour😅

 

 

 

Avatar

Community Advisor

@kbitra1998 You should be able to get value in logger.info as well, not sure how are you passing parameters to logger. Did you get a chance to print the same variables/parameters using system.out.println(for testing purpose)?

Avatar

Level 4

The mistake I have made is logger.info ("AEM" + parameter) it is printing in the logs. However, if I put logger.info("AEM", parameter) it is not printing in the logs.

Avatar

Level 5

Check if formdata that you are passing are properly populated in your javascript. You can print that in console and check.

Sharing the code that works for me:

var formData = new FormData($("#formId")[0]);

Make sure in your form you have all your inputs set with name and value, name matching with the request parameter name that you fetch in the servlet.