10 Replies Latest reply on May 17, 2013 12:20 PM by Sai Ratna

    How to allow CQ Servlet URL in Dispatcher

    Sai Ratna Level 1

      Hi,

       

      I have a servet which extends which has "sling.servlet.paths" value as "/bin/myproject/testurl".

       

      In my dispatcher.any file I have added forllowing configuration in /filter section.

       

      /0189 { /type "allow"  /glob "GET /bin/myproject/*" }

       

      And I have added following Rewrite Rule in my virtual host configuration.

       

      RewriteRule ^/bin/myproject/(.*)$ /bin/myproject/$1 [PT]

       

      With above configuration in place if I access "/bin/myproject/testurl" through dispatcher URL, I am able to get valid response (200 status code) from publish instance.

       

      The problem I am facing is, if I pass any query parameters along with servlet URL, dispatcher is returing a 404 Error.

       

      e.g. If I access "/bin/myproject/testurl?testparam=testvalue" through dispatcher URL, dispatcher returns 404 Error.

       

      However if I access "/bin/myproject/testurl?testparam=testvalue" through publish instance, it returns 200 status code.

       

      Is there any other configuration I need to add to my dispathcer.any file or virtual host configuration to handle the query parameters for servlets?

       

       

      Thanks,

      sai

        • 1. Re: How to allow CQ Servlet URL in Dispatcher
          Yogesh Upadhyay Level 4

          What error you see in dispatcher log,

           

          can you replace

           

          /0189 { /type "allow"  /glob "GET /bin/myproject/*" }

           

          With

           

          /0189 { /type "allow"  /glob "* /bin/myproject/*" }

           

          Also I am not sure what is this rewrite rule mean (You are rewrititng to same destination so it is kind of no effect)

           

          RewriteRule ^/bin/myproject/(.*)$ /bin/myproject/$1 [PT]

           

          Yogesh

          • 2. Re: How to allow CQ Servlet URL in Dispatcher
            Sai Ratna Level 1

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Found farm website1 for test.com

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] checking [/bin/myproject/testurl/]

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] no cache due to missing extenson in uri: /bin/myproject/testurl/

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] cache-action for [/bin/myproject/testurl/]: NONE

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] connected to render rend01 (127.0.0.1:4503)

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: user-agent

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: accept-charset

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: accept-encoding

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: accept-language

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: accept

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: host

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: cookie

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Detected: chunked transfer encoding

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] response.status = 404

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] response.headers[Server] = "Day-Servlet-Engine/4.1.24 "

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] response.headers[Content-Type] = "text/html;charset=utf-8"

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] response.headers[Date] = "Fri, 17 May 2013 18:27:12 GMT"

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] response.headers[Set-Cookie] = "JSESSIONID=0bbd6072-b6be-429c-93b9-5366f27ee54d; Path=/; HttpOnly"

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] send http headers

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Content length: -1, written: 451

            [Fri May 17 23:57:12 2013] [I] [8568(1272)] "GET /bin/myproject/testurl/?testparam=testvalue" 404 439 50ms

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Found farm website1 for test.com

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] checking [/favicon.ico]

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] cachefile does not exist or is a directory: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\favicon.ico

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] try to create new cachefile: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\favicon.ico

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] cache-action for [/favicon.ico]: CREATE

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] connected to render rend01 (127.0.0.1:4503)

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: user-agent

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: accept-charset

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: accept-encoding

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: accept-language

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: accept

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Spooling header: host

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Detected: chunked transfer encoding

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] response.status = 404

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] response.headers[Server] = "Day-Servlet-Engine/4.1.24 "

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] response.headers[Content-Type] = "text/html;charset=utf-8"

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] response.headers[Date] = "Fri, 17 May 2013 18:27:12 GMT"

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] response.headers[Set-Cookie] = "JSESSIONID=9a5a9858-d94e-4119-a681-0204cceadcd2; Path=/; HttpOnly"

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] send http headers

            [Fri May 17 23:57:12 2013] [D] [8568(1272)] Content length: -1, written: 432

            [Fri May 17 23:57:12 2013] [I] [8568(1272)] "GET /favicon.ico" 404 420 50ms

            • 3. Re: How to allow CQ Servlet URL in Dispatcher
              Yogesh Upadhyay Level 4

              What happen for this request /bin/myproject/testurl.html?testparam=testvalue

               

              Yogesh

              • 4. Re: How to allow CQ Servlet URL in Dispatcher
                Sai Ratna Level 1

                I tried changing the filter as per your suggestion, still I am getting the same error.

                • 5. Re: How to allow CQ Servlet URL in Dispatcher
                  Sai Ratna Level 1

                  127.0.0.1 - - [17/May/2013:23:57:12 +0530] "GET /bin/myproject/testurl/?testparam=testvalue" HTTP/1.1" 404 301 "test.com"

                  • 6. Re: How to allow CQ Servlet URL in Dispatcher
                    Yogesh Upadhyay Level 4

                    I am not sure why dispatcher is adding "/" in the end of url (Thats why asked you to try with .html extention). Can you enable rewrite log and see if there is any other rewrite rule causing this.

                     

                    Yogesh

                    1 person found this helpful
                    • 7. Re: How to allow CQ Servlet URL in Dispatcher
                      Sai Ratna Level 1

                      How to enable rewrite log?

                      • 8. Re: How to allow CQ Servlet URL in Dispatcher
                        Sai Ratna Level 1

                        Hi Yogesh,

                         

                        By Changing the following [1] to [2]. It solved the issue.

                         

                        [1]     RewriteRule ^/bin/myproject/(.*)$ /bin/myproject/$1 [PT]

                        [2]     RewriteRule ^/bin/myproject/(.*)$ /bin/myproject/$1 [L, PT]

                        • 9. Re: How to allow CQ Servlet URL in Dispatcher
                          Yogesh Upadhyay Level 4

                          Sai,

                           

                          If that is case that mean there was some other rewrite rule that was messing up. By changing rule above you are essentially saying apache rewrite module that this is last rule in chain.

                           

                          Yogesh

                          • 10. Re: How to allow CQ Servlet URL in Dispatcher
                            Sai Ratna Level 1

                            Yes. There was another rewrite rule which was appending a / at end of url, for the urls not ending with .html