I have a case where I need to read URL's and dynamically redirect to the right product listing page. i.e. When hitting a product detail page, if the current product is out of stock, I want to handle logic and redirect to a product listing page that displays products within the same category.
What is the best approach to this which is also SEO friendly? Would there be a way to dynamically redirect within the dispatcher or is this something a custom Java Servlet should handle?
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
I agree with @Anish-Sinha , but rather than handling via servlet the best approach (in my personal opinion
eg:
Hope this helps
Veena ✌
Hi @akatsuki07 ,
There has to be a logic based on which the page should redirect. To check if the product is out of stock, the call has to go to the server to get the count. Dispatcher won't be able to handle this since there is no identifier that dispatcher would have for out of stock product.
You can handle this logic in your client side code (javascript) if the product component is using ajax. From there is the response for it is out of stock you can forward the request in js snippet using
window.location.href="target page path"
Else you can handle it in model class or servlet.
I agree with @Anish-Sinha , but rather than handling via servlet the best approach (in my personal opinion
eg:
Hope this helps
Veena ✌
Views
Likes
Replies