5 Replies Latest reply on Jul 15, 2013 9:20 AM by Yogesh Upadhyay

    How to write a custom post Handler?

    MGEB

      I am trying to implement a custom post request handler instead of using the default SlingPostServlet. I followed the steps below but the request is still being handled by default post servlet.

       

      • In CRDX Lite, I created a component called imageUpload under
         /apps/training/components/page
      • Added a JSP file under the imageUpload node and renamed it
        imageUpload.POST.jsp 
      • Created a template imageUploadTemp under
        /apps/training/templates/
      • Updated the sling:resourceType property of the template to
        /apps/training/components/page/ImageUpload
      • Created a page named imageUpload under the project Training Site using the template above. 

       

      The problem is that when submitting a post request to the page(http://localhost:4502/content/training_site/ImageUpload.html) the request is still being redirected to the default servlet. One thing to mention regarding the post request being submitted is that I am not using HTML form to submit the post request. Instead I use Apaches DefaultHttpClient also the request is a multipart request as I am uploading a file.

       

      Can you please help me in pointing out what I missed?

       

      You may also ask why I am not using the default servlet to upload file directly instead of using a custom one, the problem is the default servlet doesn't have any means to create a node of type DAM Assets (dam:Asset) with the full metadata and rendition structures. If there is any way to accomplish this without writing a custom post handler, it will be a better approach to my problem.

       

      I am using CQ5.4

       

      Thank you,