Home AEM Custom component for page redirect
Reply: 0

AEM Custom component for page redirect

user1051
1#
user1051 Published in May 20, 2018, 11:57 am

I am trying to create a custom component for page redirect. The use case is pageB should be accessible only via pageA. If pageB is accessed directly then user should be redirected to pageA. In order to achieve this, I am setting a variable in pageA's request scope. In pageB i will be including a component(drag and droppable), which will look for pageA's request scope variable and if it is not available then we pageB will be redirected, using below snippet.

private void redirect(SlingHttpServletRequest request) {
    String redirectPath = "/content/geometrixx/home.html";        
    if (StringUtils.isNotBlank(redirectPath)) {           
        getResponse().setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
        getResponse().setHeader(redirectPath);
    } else {
        LOGGER.error("Redirect path is not set in component");
    }
}

But the above code is failing. I believe it is due to "response already committed" error.

Can someone suggest me a way out for this problem?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.303202 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO