Skip to main content
Level 4
Jan 29, 2016 4:50 AM UTC
Solved

How call AEM Servlet in JSP's form tag not via Ajax

Hi 

We have one senario and created the drop-zone by using the dropzone.js. Now when we are trying to drop the assets in dropzone area then calling AEM servlet via form tag like:

<form method="POST" action="/bin/myServlet" class="dropzone" id="myDropzone" enctype="multipart/form-data"></form>

but getting error message like:

POST:http://localhost:4502/bin/myButtonServlet 403 forbidden

Any Idea? Are we missing anything?

Thanks

Samer

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Kunal_Gaba_
Kunal_Gaba_Accepted solution
New Member
Jan 29, 2016 4:54 PM UTC

For ideal solution, you should include the following javascript on your page - /etc/clientlibs/granite/jquery/granite/csrf/source/csrf.js. You can include it by doing a standard client library include call in your JSP. 

<cq:includeClientLib js="granite.csrf.standalone"/>

For more details go through this- 

[1] https://docs.adobe.com/docs/en/aem/6-1/develop/security/csrf-protection.html

[2] http://blogs.adobe.com/experiencedelivers/experience-management/clientlibs-explained-example/

15 replies

Mani_kumar_
Community Advisor
Community Advisor
Jan 29, 2016 12:26 PM UTC
Hi Can you please check all the annotations related to the servlet and check any exception is throwing in the logs
Translate
smacdonald2008
Level 10
Jan 29, 2016 1:06 PM UTC

Hi Samer - are you following a online doc for this. Can you point me there if so. 

Translate
Level 4
Jan 29, 2016 4:17 PM UTC

Hi Kunal

I  just remove the CSRF configuration temporarily and POST entry and checked it is working. For ideal solution do you have any sample  like to pass the token or user related information. 

Hi Opkar,

Yes, the test user logged in and trying to use the page inside AEM and trying to call the servlet

Thanks

~S

Translate
Kunal_Gaba_
Kunal_Gaba_Accepted solution
New Member
Jan 29, 2016 4:54 PM UTC

For ideal solution, you should include the following javascript on your page - /etc/clientlibs/granite/jquery/granite/csrf/source/csrf.js. You can include it by doing a standard client library include call in your JSP. 

<cq:includeClientLib js="granite.csrf.standalone"/>

For more details go through this- 

[1] https://docs.adobe.com/docs/en/aem/6-1/develop/security/csrf-protection.html

[2] http://blogs.adobe.com/experiencedelivers/experience-management/clientlibs-explained-example/

Translate
Jitendra_S_Toma
Level 10
Jan 29, 2016 4:59 PM UTC

Check out more usefull docs...

Jitendra

Translate