Hi All,
I have written sling servlet and i want to check if it's working propelrly.
Before including in component and i want to check whether it's returning data properly.
I heard we can call from browser and check the same.
Can some one help how to execute like this
Thanks,
Kishore
Solved! Go to Solution.
Hi Kishore,
Why are you declaring it as a service and a component? Try and create a simple servlet and see if that works.
I don't see the declaration for it being a servlet e.g.
Regards,
Opkar
[1https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html
Views
Replies
Total Likes
We have this documented in this community article:
https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html
Views
Replies
Total Likes
i am calling in the same way but 404 is coming.
My Servlet code looks as below.
@Component(name = "com.symantec.elibrary.core.servlets.ProductManagementServlet", label = "Product Management servlet", description = "This servlet filters the doctypes", specVersion = "1.1", metatype = true, immediate = true, policy = ConfigurationPolicy.REQUIRE)
@Service
@Properties({
@Property(name = "service.description", value = "Symantec ProductManagementServlet Service"),
@Property(name = "service.vendor", value = "Symantec Corporation."),
@Property(name = "sling.servlet.paths", value = "/c/symantec/servlets/ConnectToSABA", propertyPrivate = true),
@Property(name = "sling.servlet.methods", value = "GET", propertyPrivate = true)})
public class ProductManagementServlet extends SlingAllMethodsServlet{
private static final long serialVersionUID = 1L;
/** Default log. */
protected final Logger log = LoggerFactory.getLogger(ProductManagementServlet.class);
/**
* The set of argument type classes for the reflection method calls.
*/
@SuppressWarnings("rawtypes")
protected static final Class[] parameterTypes = { SlingHttpServletRequest.class, SlingHttpServletResponse.class };
public void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException,
IOException {
try {
response.setContentType("application/json");
JSONObject jsonObj = new JSONObject();
jsonObj.put("Key1", "Value1");
response.getWriter().print(jsonObj.toString());
}catch (Exception e) {
log.error("Exception in doGdet() method", e);
return;
}
}
/**
* This method is called the OSGI framework when the bundle is activated. It
* reads the properties from the component context.
*
* @param componentContext
*/
@SuppressWarnings("rawtypes")
public void activate(ComponentContext componentContext) {
log.debug("Entering activate method.");
Dictionary properties = componentContext.getProperties();
if (null != properties) {
// /
}
log.debug("Exiting activate method.");
}
/**
*
* @param componentContext
* @throws RepositoryException
*/
protected void deactivate(ComponentContext componentContext) {
log.debug("Entering deactivate method.");
log.debug("Exiting deactivate method.");
}
}
Thanks.
Kishore
Views
Replies
Total Likes
Hi Kishore,
Why are you declaring it as a service and a component? Try and create a simple servlet and see if that works.
I don't see the declaration for it being a servlet e.g.
Regards,
Opkar
[1https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html
Views
Replies
Total Likes
@Opkar_Gill Links on this page are no longer available. Please refresh for AEM 6.5 content or retire/remove/deactivate page. (Saves us a little time in the field when searching for solutions.)
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies