Sling servlet binding using resourceTypes,is it visible in Sling Servlet Resolver ?

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,134 likes

Total Posts

3,161 posts

Correct reply

1,079 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,134 likes

Total Posts

3,161 posts

Correct reply

1,079 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

24-04-2019

What is the resource type of /content/mypage (visible as property in /content/mypage/jcr:content)? It should be "p1App/components/structure/samplePage".

Jörg

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

22-04-2019

@aem_marc ,@smacdonald2008 Guys , can you please help me out ?