Invoking Servlet | Community
Skip to main content
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 raj_mandalapu

Check this, it covers all possible ways

http://www.aemcq5tutorials.com/tutorials/sling-servlet-in-aem/

2 replies

raj_mandalapu
raj_mandalapuAccepted solution
Level 7
October 11, 2018
raj_mandalapu
Level 7
October 11, 2018

Generally, you can call servlet different ways

You can call it using AJAX request, which normally you use to load the content without refreshing entire page

$("button").click(function(){

    $.ajax({url: "/bin/servlet", success: function(result){

        $("#div1").html(result);

    }});

});

You can also use HTML form action to call servlet

<form action="/bin/servlet" method="get">

  First name: <input type="text" name="fname"><br>

  Last name: <input type="text" name="lname"><br>

  <input type="submit" value="Submit">

</form>

  • You can directly call the servlet by hitting the servlet URL in the browser
  • You can also call servlet in dialog to populate drop down list etc.

Adobe Experience Manager Help | Populating AEM Component Dialog fields using JSON data returned by Sling Servlets

In AEM most of the time, we use AJAX approach and populating dialog fields which are step 1 and 4