How to get request parameter of SlingServlet in OSGi Service ? | Community
Skip to main content
Suraj_Kamdi
Community Advisor
Community Advisor
October 30, 2018

How to get request parameter of SlingServlet in OSGi Service ?

  • October 30, 2018
  • 1 reply
  • 12074 views

I want to fetch the properties in OSgi Service like userName , which is set in request parameter in a my custom SlingServlet ? Anyone has an idea about how to achieve this task ?

I have one RegisterUserSlingServlet class and CustomMailService as OSGi service. I want get some request parameters properties inside my CustomMailService.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

chandu_t
Level 3
October 30, 2018

Assuming you call CustomMailService in RegisterUserSlingServlet. You get request parameters in servlet by request.getParameter("key"). You can pass this parameters to the service, while invoking service method.

Feike_Visser1
Adobe Employee
Adobe Employee
October 30, 2018

Indeed, just pass in the request object or individual values

Suraj_Kamdi
Community Advisor
Community Advisor
October 30, 2018

Then create a custom method in service. And call it.

  public void send(Email email, String targetUrl) throws MailingException {

     //Here use targetUrl for condition

  }

  Add call like below in servlet

  mailService.send(email, request.getParameter("targetUrl"));


chandu t​ But

@Override

  public void send(Email email) throws MailingException {} is an interface method