11 Replies Latest reply on Sep 25, 2018 4:26 PM by fru92thu

    APEX 18.1 - Redirect to URL

    fru92thu

      Hello,

       

      We have an APEX page - with 2 Interactive reports (1 called CSV DATA).

       

      2 date pickers - start date and end date.

      2 buttons - run report and downloadtocsv

       

      There is a hidden page item with type - SQL Query and the sql query is;

       

      select region_id

      from apex_application_page_regions

      where application_id = :app_id

      and page_id = :app_page_id

      and region_name = 'CSV DATA'

       

      The downloadtocsv button has an action of "Redirect to URL" with a url of https://........./f?p=&APP_ID.:&APP_PAGE_ID.:&SESSION.:IR[R&89_CSV_REGION.]_CSV:ClearCache:

       

      The CSV DATA interactive report runs a SQL query.

       

      Now when the user clicks on downloadtocsv, the CSV DATA SQL should run and get exported to csv but instead it gives an HTTP 400 error.

       

      *** This worked in APEX 5.1.3

       

      Any help would be appreciated. For this use case we cannot use the built-in download to csv option.

       

      Regards,

      David

        • 1. Re: APEX 18.1 - Redirect to URL
          Carsten Czarski-Oracle

          Hi David,

           

          could you provide a bit more information ...?

           

          -) right click the button and post the generated URL here ...?

          -) Any error message which might come together with the HTTP-400

          -) Did you also do an ORDS upgrade in addition to the APEX upgrade ...?

           

          ... of course, the best option would be to reproduce the problem on apex.oracle.com - then we can have a look ...

           

          Here is one idea (but that is just a shot into the blue): You have square brackets in your redirect URLs. Some web servers choke on this, so you might want to use %5B instead of [ and %5D instead of ].

          I assume that the generated URL is somehow malformed ...

           

          Best regards

           

          -Carsten

          • 2. Re: APEX 18.1 - Redirect to URL
            fru92thu

            Carsten

             

            I did a simple test case on apex.oracle.com but it didn't give an error which is frustrating. The simple test case gives an HTTP 400 on our environment.

             

            -) right click the button and post the generated URL here ...?

             

            javascript:apex.navigation.redirect('https:%5Cu002F%5Cu002Fwww.mdummyyurl.com%5Cu002Fapex%5Cu002Fpobeu%5Cu002Ff?p=116:264:116220038507937:IR[R]_CSV:ClearCache:');

             

            -) Any error message which might come together with the HTTP-400

            This page isn’t working

            If the problem continues, contact the site owner.

             

            HTTP ERROR 400

             

            -) Did you also do an ORDS upgrade in addition to the APEX upgrade ...?

            Yes, we upgraded from ORDS 17.4 to 18.2

             

            If I replace the [ ] as you say above the button doesn't work in apex.oracle.com or in our environment. No error is given, just nothing happens when you click it

             

            Regards,

            David

            • 3. Re: APEX 18.1 - Redirect to URL
              Carsten Czarski-Oracle

              Hi David,

               

              that's odd ... so the same test case ...

               

              -) produces the error on your environment

              -) does not reproduce the error on apex.oracle.com

               

              Is that correct?

               

              Let's have a look into the web server. You said that you also upgraded to ORDS 18.2. Are you using ORDS standalone ...? Within Tomcat / Weblogic? Is the environment front-ended by another web server ...?

               

              The URL which you have posted clearly shows that some escaping took place. Interestingly, the first part of the URL has been escaped (http://www.mydummyurl.com/apex/pobeu/), whereas the rest of the URL remained unescaped ...

               

              What do you get if you invoke the following query in SQL Workshop?

               

              select apex_util.host_url('SCRIPT') from dual;

               

              Best regards

               

              -Carsten

              • 4. Re: APEX 18.1 - Redirect to URL
                fru92thu

                Hi Carsten

                 

                That's correct - the same testcase works in apex.oracle.com and not in our environment.

                 

                ORDS 18.2 on Tomcat 8.5.32. There is a network load balancer in front of this but I doubt this is causing any issues as it is unchanged since the APEX and ORDS upgrades.

                 

                I just replaced our domain name with mydummyurl for security.

                 

                I was going to turn on ORDS debugging and restart Tomcat (we have multiple servers with this setup with load balancing so I can do this without an outage). Hopefully I'll get more meaningful output when the HTTP 400 is displayed.

                 

                 

                Regards,

                David

                • 5. Re: APEX 18.1 - Redirect to URL
                  Carsten Czarski-Oracle

                  Hi David,

                   

                  there a known issue, which might be related to this: Bug #28013850 (web server errors because of non-compliant special chars {} in url). The symptom in this case is also an HTTP-400.

                   

                  That bug will be fixed in the upcoming release of APEX as well as in the "Bundle PSE" which is available for 18.1. To apply the Patch Bundle, navigate to My Oracle Support, look up and download patch number 28128115.

                   

                   

                  Best regards

                   

                  -Carsten

                  • 6. Re: APEX 18.1 - Redirect to URL
                    fru92thu

                    Applying that patch now. Will report back with the result.

                     

                    Regards,

                    David

                    • 7. Re: APEX 18.1 - Redirect to URL
                      fru92thu

                      That patch didn't work and we are stumped.

                       

                      I turned on ORDS debugging and restarted Tomcat, although nothing further was returned to the screen when the HTTP 400 was experienced.

                       

                      The Tomcat localhost access log shows;

                       

                      [25/Sep/2018:16:21:25 +0100] "GET null null" 400 -

                      • 8. Re: APEX 18.1 - Redirect to URL
                        Carsten Czarski-Oracle

                        Hi David,

                         

                        what's in catalina.out ...? ORDS messages should be there. The access log just contains one line per invocation.

                         

                        Best regards

                         

                        -Carsten

                        • 9. Re: APEX 18.1 - Redirect to URL
                          fru92thu

                          Catalina.out shows;

                           

                          25-Sep-2018 16:54:15.475 INFO [http-nio-8080-exec-9] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header

                          Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

                          java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

                                  at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:479)

                                  at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:684)

                                  at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

                                  at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800)

                                  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471)

                                  at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

                                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

                                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

                                  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

                                  at java.lang.Thread.run(Thread.java:748)

                          • 10. Re: APEX 18.1 - Redirect to URL
                            Carsten Czarski-Oracle

                            Hi David,

                             

                            that starts to shed at least a bit of light into this issue .....

                             

                            However, it's still difficult since the problem does not occur on apex.oracle.com or another environment. It seems to be the combination of APEX, ORDS and your load balancer.

                             

                            Since tomcat coughs on parsing the actual HTTP request we might have a look into it. When you click that button ... could you open the Developer Console (F12) and monitor the "Network" tab. There should be a line for the failing request - and clicking on it should show more details on the HTTP request (including HTTP headers) ...

                             

                            Best regards

                             

                            -Carsten

                            • 11. Re: APEX 18.1 - Redirect to URL
                              fru92thu

                              Turns out that in recent versions of Tomcat you need to include ;

                               

                               

                              relaxedQueryChars="[,]"

                               

                               

                              in the Tomcat server.xml file connector section to allow some special characters to be displayed in the URL.

                               

                              I did this and restarted Tomcat and it works. No more HTTP 400 error.

                               

                              Thanks for the assistance and pointing me in the right direction!

                               

                              Regards,

                              David