@SantoshSai My Apology. I forgot to add the exact code. I have modified the code above. Please have a look. And by the way, there is no specific error in the error log.
Just getting this - "org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: org.apache.sling.api.resource.ResourceNo...