for doPost servlet, SlingHttpServletRequest getting empty | Community
Skip to main content
New Participant
February 16, 2022
Solved

for doPost servlet, SlingHttpServletRequest getting empty

  • February 16, 2022
  • 2 replies
  • 1681 views

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.

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

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😅

 

 

 

2 replies

ibishika
New Participant
February 16, 2022

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.

Nitin_laad
New Participant
February 16, 2022

@kbitra1998 can you share code snippet using to read post request data in servlet?

check this out, if it solves your problem

javascript - Servlet in AEM, body in POST request is lost - Stack Overflow

 

kbitra1998AuthorAccepted solution
New Participant
February 18, 2022

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😅

 

 

 

Nitin_laad
New Participant
February 18, 2022

@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)?