Expand my Community achievements bar.

SOLVED

Invoking Servlet

Avatar

Level 2

How to invoke a servlet in AEM? Suggest me steps , methods or process if any.

1 Accepted Solution

Avatar

Correct answer by
Level 8
2 Replies

Avatar

Correct answer by
Level 8

Avatar

Level 8

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 S...

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