Posting data to POST.jsp | Community
Skip to main content
July 28, 2016
Solved

Posting data to POST.jsp

  • July 28, 2016
  • 6 replies
  • 4562 views

Hi Team,

I am trying to post table data from my form to the POST.jsp using the following approach.

$.ajax({
                type: 'POST',
                url: '/url to the component's node/Organization.POST.jsp',
                data: {
                    'orgName': orgName,
                    'orgPhNum': orgPhNum,
                    'orgProgram': orgProgram,
                    'orgAddress': orgAddress,
                    'orgCity': orgCity,
                    'orgState': orgState,
                    'orgZipCode': orgZipCode,
                    'datePicker': datePicker,
                    'problemReproducible': problemReproducible,
                    'locations': locationArr,
                    'people': peopleArr,
                    'fileDetails': fileArr
                },
                success: function(data) {
                    //alert(data);
                },
                failure: function(data) {
                    //alert("failed");
                }
            });
        }); 

 I was able to get all the data in Servlet for a different case following the same approach .Not sure what path to give to make it work for POST.jsp as well

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 kautuk_sahni

Hi 

There is one more Helpx Article that is uploading an image. Here also we are posting image stream via POST method, and at the OSGI level (servlet) we are catering it with doPost ();

Link:- https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html

// Here we are sending FormData Via Ajex call which is having POST as a Method.

    $.ajax({
    type: 'POST', 
    url:'/bin/updamfile',
    processData: false, 
    contentType: false, 
    data:formData,
    success: function(msg){
        alert(msg); //display the data returned by the servlet
}
});

 

Please have a look at this one, i hope this would help you.

Thanks and Regards

Kautuk Sahni

6 replies

smacdonald2008
July 28, 2016

Posting data to a post.POST.jsp is typically from an Adoptive form. See: 

https://helpx.adobe.com/experience-manager/using/posting-aem-6-form-data.html

If you are using AJAX outside of an adaptive form (ie - a JSP) - consider posting to an AEM Sling Java Servlet. 

See: 

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

July 28, 2016

Was able to post form(Non adaptive one) details to servlet.

It had issues then accessing the Datasource Connection defined in the osgi configurations.

That is the reason I tried using POST.jsp approach.

smacdonald2008
July 28, 2016

If you want to store data into a relational database from a servlet - use a DataSourcePool. This is the best practice. See this AEM community article that shows how to perform this use case: 

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets1.html

This shows you How To get a DataSourcePool into a Sling Servlet. This way you can post to Servlet and then use DataSourcePool to get the data into a database. 

July 31, 2016

Thanks for your response.

I tried using the shared article and ended up getting "No suitable driver found error".

I have the Oracle driver jar installed as bundle and I am able to connect to database using Data connection pool when using POST.jsp upon HTML form submission in AEM. 

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
August 1, 2016

Hi 

There is one more Helpx Article that is uploading an image. Here also we are posting image stream via POST method, and at the OSGI level (servlet) we are catering it with doPost ();

Link:- https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html

// Here we are sending FormData Via Ajex call which is having POST as a Method.

    $.ajax({
    type: 'POST', 
    url:'/bin/updamfile',
    processData: false, 
    contentType: false, 
    data:formData,
    success: function(msg){
        alert(msg); //display the data returned by the servlet
}
});

 

Please have a look at this one, i hope this would help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
smacdonald2008
August 25, 2016

Make sure you have the JSP files you are posting to in the correct location. See this example whick works:  https://helpx.adobe.com/experience-manager/using/querying-experience-manager-sling.html