Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Who Me Too'd this topic

Avatar

Avatar
Validate 1
Level 1
pavanh77
Level 1

Like

1 like

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
pavanh77
Level 1

Like

1 like

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
pavanh77
Level 1

17-04-2019

Hi Team,

I have created one simple servlet using resourceTypes ,

Below is my code snippet  "

@Component(service=Servlet.class ,property={ Constants.SERVICE_DESCRIPTION + "=Simple Medicine Servlet",

"sling.servlet.methods=" + HttpConstants.METHOD_GET, "sling.servlet.paths=" + "/bin/mySimpleservlet1",

"sling.servlet.resourceTypes=" + "p1App/components/structure/samplePage" , "sling.servlet.selectors=" + "groups"})

public class ResourceServlet extends SlingSafeMethodsServlet{

private static final long serialVersionUID = 1L;

@Override

protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)

throws ServletException, IOException {

PrintWriter out = response.getWriter();

out.println("Servlet is called by resourceType!!!!!");}

}"

Case 1: By Path

When i hit the URL localhost:4502/bin/mySimpleservlet1  on browser getting output Servlet is called by resourceType!!!!!

&  I am looking in Sling Servlet Resolver , by Path is visible.

To call above servlet i wrote Ajax call as well ,

$.ajax({

         type: 'GET',   

         url: 'bin/mySimpleServlet1',

         data:{"pageurl":"/content/p1App/mypage/jcr:content/par/mastercomponent/medicine"},

         success: function(msg){

                     console.log(msg);  }

     });

Case 2 : By resourceTypes

When i hit the URL localhost:4502/content/mypage.groups.html on browser getting output Servlet is called by resourceType!!!!!

&  I am looking in Sling Servlet Resolver resourceTypes is not visible.

a) Can we see th servlet by resourceTypes is resolved in Sling Servlet Resolver ?

b) Can you please tell what to mention in ajax call to get servlet using resourceTypes?

Also let me know if you need more details.

Thanks in advance.

Regards,

Pavan

Who Me Too'd this topic