Expand my Community achievements bar.

SOLVED

Content redirect on form handler AEM 5.6.1

Avatar

Level 3

Hi guys,

I am submitting a simple feedback form to a form handler in AEM 5.6.1. The submission is being made by JQuery $.post(). The post submits to a CQ page which contains a single component to handle the form input and send an email. Really simple stuff.

If I access the form handler page directly in my browser, the code on it runs and a blank email is sent. However, when I submit the form (via JQuery or directly via HTTP POST) the response from CQ is as follows (seen here in the developer tools of Chrome with URLs redacted):

[img]problem.jpg[/img]

Can anyone tell me why the form handler page (or any page for that matter) responds like this when a form is submitted to it (via POST)?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

The problem is, that your code to submit an EMail is obviously built to handle only GET requests. And when you use a POST request (like jquery does), the default POST operation (Sling Default POST servlet) is used, as there is no other servlet there to handle it.

So you should enable your component to handle POST requests as well; you can do this either using a JSP (just put a POST.jsp next to the other ones, see [1]); or you define a servlet to handle all POST requests for this resourceType [2].

HTH,

Jörg

[1] http://dev.day.com/content/ddc/blog/2010/08/understanding_howsc.html

[2] https://sling.apache.org/documentation/the-sling-engine/servlets.html

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

Hi,

The problem is, that your code to submit an EMail is obviously built to handle only GET requests. And when you use a POST request (like jquery does), the default POST operation (Sling Default POST servlet) is used, as there is no other servlet there to handle it.

So you should enable your component to handle POST requests as well; you can do this either using a JSP (just put a POST.jsp next to the other ones, see [1]); or you define a servlet to handle all POST requests for this resourceType [2].

HTH,

Jörg

[1] http://dev.day.com/content/ddc/blog/2010/08/understanding_howsc.html

[2] https://sling.apache.org/documentation/the-sling-engine/servlets.html