How to pass resorceType/Path in form in AEM | Community
Skip to main content
manikanthar1295
Level 5
February 27, 2019
Solved

How to pass resorceType/Path in form in AEM

  • February 27, 2019
  • 3 replies
  • 2361 views

Hi Team,

I have two fields  like AWB number and Reference number as input text  now

how i need to pass the entered value in text  to sling servlet.

I know if i use ajax i can give the path defined in  slingServlet as URL

$.ajax({

         type: 'POST',   

         url:'/bin/htlSearchServlet',

         data:'id='+ claimId+'&firstName='+ myFirst+'&lastName='+ myLast+'&address='+ address+'&cat='+ cat+'&state='+ state+'&details='+ details+'&date='+ date+'&city='+ city,

         success: function(msg){

           var json = jQuery.parseJSON(msg);

            var msgId=   json.id;

            var lastName = json.lastname;

            var firstName = json.firstname;

             

            $('#ClaimNum').val(msgId);

            $('#json').val("Filed by " + firstName + " " + lastName);  

         }

     });

  });

If i'm not using ajax call

Where i need to specify the resourceType or Path in form.

Please let me know how we can do this.

Regards

Manikantha R

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 vaibhavs7024655

manikanthar12951933 You can set those values to the request parameters and then fetch them in servlet using SlingHttpServletRequest's getRequestParameters(String name) method[1].

Regards,

Vaibhav

[1]

SlingHttpServletRequest (Apache Sling 7 API)

3 replies

Prince_Shivhare
Community Advisor
Community Advisor
February 27, 2019

I understood your requirement but not sure why you are not using Ajax. it is best and easy way to call servlet. probably you can tell what issues you are facing by using Ajax

if you still want to do it please check the below URL. and pass the bin url in servleturl. for this you will have to use JSP.

<form action="servletURL" method="post">

How to call servlet through a JSP page - Stack Overflow

~ Prince

smacdonald2008
Level 10
February 27, 2019

WHen you want to pass given values to a backend Servlet - using AJAX is a standard way. It's event-driven and typically is fired when a user clicks a button on a page - as opposed to when a resource loads in AEM.

vaibhavs7024655
vaibhavs7024655Accepted solution
Level 3
February 28, 2019

manikanthar12951933 You can set those values to the request parameters and then fetch them in servlet using SlingHttpServletRequest's getRequestParameters(String name) method[1].

Regards,

Vaibhav

[1]

SlingHttpServletRequest (Apache Sling 7 API)