Hi Folks,
I need to write a sling servlet either part type or resource type anything is acceptable
1. Extension less
2. Selector less
Something like below
localhost:4502/mysite?param1=val1¶m2=val2
Path type servlet always need 2 level of hierarchy i.e. /bin/ or /mysite/, Can it have path without trailing slash and only one level of script resolution like /mysite
I tried but no luck.
Please advise
Thanks,
Pradeep
Solved! Go to Solution.
Views
Replies
Total Likes
The problem with these URLs is that the dispatcher is not able to cache a URL without an extension. That means you should rewrite your URLs on the dispatcher to contain extensions.
(And of course query strings also prevent the dispatcher from caching the files...)
Hi @pradeepdubey
Can you please check if you have specified the path in Apache Sling Servlet / Script Resolver and Error Handler in config manager console if you registering the servlet through path.
Also you should be able to register it through resourceType, please share the code snippet of your ajax call and servlet registration.
It is registered in osgi config error handler.
/mysite
Hoever it is not working.
It is working when I register as
/mysite/
and servlet path as /mysite/myservlet then it is working.
My requirement is to make the sling servlet working at path /mysite only.
localhost:4502/mysite?param1=val1
Code is given below
@component(service=Servlet.class,
property={
Constants.SERVICE_DESCRIPTION + "=Mysite Servlet",
"sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.paths=/mysite"
})
public class MySiteServlet extends SlingSafeMethodsServlet {
private static final long serialVersionUID = 1L;
private transient Logger log = LoggerFactory.getLogger(MySiteServlet.class);
@Override
protected void doGet(final SlingHttpServletRequest req,
final SlingHttpServletResponse resp) throws ServletException, IOException {
log.info("Entering doGet");
String val1 = req.getParameter("param1");
log.info("val1 {}", val1);
}
}
The problem with these URLs is that the dispatcher is not able to cache a URL without an extension. That means you should rewrite your URLs on the dispatcher to contain extensions.
(And of course query strings also prevent the dispatcher from caching the files...)
Views
Likes
Replies
Views
Likes
Replies