RequestDispatcher.forward not working properly
I am calling a java class implementing WCMUse in template's(page component's) sightly (.html) where I am checking something and based on that I need to forward to some other cq page. The issue I am facing here is that the content of the current page remains intact and on top of it, the content of the page to which i want to forward to is being rendered. So I see the forward page and below that I see the header footer content etc again of the current page from where I am forwarding. Ideal behaviour that I need here is like only the content of the page where we are forwarding should come and current page's content should not appear. Java code snippet written in
slingRequest.getRequestDispatcher(pathofthepagetoforward).forward(slingRequest, slingResponse);
Please suggest any solution or may be I am doing something wrong here according to AEM.