5 Replies Latest reply on Jun 19, 2014 8:39 AM by steve_ssh

    How to capture error "404 File or Directory not found", in Web Viewer

    EvanGoldstein

      Hello,

       

      I have a web viewer that justifiably will show the error "404 - File or directory not found", when there is no page to display for some records.

      What can I specify in the web viewer setup screen to have the Web Viewer either display a blank screen, or direct it to a static page that says something like "image not available".

      I essentially want to not display the default error.

       

      Using FMServer Adv ver 11, with both Mac and Windows FM 10 & 11 clients.

       

      Thanks

      Evan

        • 1. Re: How to capture error "404 File or Directory not found", in Web Viewer
          steve_ssh

          Hello Evan,

           

          Thanks for including the specific details about which versions of clients you are using -- that information helps.  There are at least a couple solutions that might have been proposed that would have required later versions of FMP clients.

           

           

          With respect to the target webviewer content which may or may not be present:

           

             1) Is the content in the form of HTML pages?  Links to raw image files?  Links to some other kind of file?  Varies depending on the current record?

           

             2) Is the content all hosted on a single server, or is it on multiple servers?

           

             3) Do you have control over the server(s) that host the content?

           

           

          Here are some ideas of the top of my head:

           

          1)  Have you considered hosting a simple shim page using something like PHP, which:

           

             - Accepts a query parameter of the target URL

             - Checks to see if the resource exists

             - If the resource exists, it returns a redirect command to the webviewer, pointed to the resource

             - If the resource does not exist, it returns a custom error message?

           

           

          2) The same shim concept could be realized without having to host the shim file -- the shim could be a local HTML file (exported from FMP) which uses Javascript (instead of server-side scripting) to determine if the resource is available.

           

           

          3) If the clients were limited to OSX, I believe that the shim could be accomplished using a data URL in the webviewer, but I believe that Windows may prevent a Javascript redirect from a data URL (security restriction).  Still:  at least one variation on this may be possible on both OSX and Windows.

           

           

          4) You might be able to use a tiny (almost invisible) web viewer which attempts to load the resource, and if a 404 page is detected, the main webviewer that the user sees could be conditionally set to show your custom error message.  This could be script driven.  It may even be possible to get something working without scripting, and just using the calculation engine with the web-viewers.  Were this v.12, you could use Insert From URL instead of a second webviewer.

           

           

          If any of the above seem worth pursuing to you and you could use a nudge to get started, please just let me know, and I'll do my best to post some kind of sample if I know which direction you are interested in.

           

          HTH & very best,

           

          -steve

           

           

          Addendum:

           

          If you control the webserver which hosts all of the target content, you might be able to achieve what you want by using a custom 404 page.

          • 2. Re: How to capture error "404 File or Directory not found", in Web Viewer
            EvanGoldstein

            Hi Steve,

             

            Thank you for the extensive list of ideas and details.

            The web viewer is just looking at images on a file server, via a web service. All of the images are jpg files. Each record in FM knows what the URL to the images is suppose to be, but if there is no file or image there as expected, the web service is displaying the error screen. I may be able to ask the web manager to change the error screen.

            There are both Window and Mac users.

            #4 sounds the easiest, but how would FM know the contents of the web viewer? Is there a way to "screen scrape" the content or detect the error?

             

            Thanks,

            Evan

            • 3. Re: How to capture error "404 File or Directory not found", in Web Viewer
              EvanGoldstein

              I found the GetLayoutObjectAttribute function, which when retruning the "content", I was able to make the Web View give a blank image, instead of the error message.

              I used the 2nd small web viewer to determine what the content was to check.

               

              Thanks for your help.

              • 4. Re: How to capture error "404 File or Directory not found", in Web Viewer
                steve_ssh

                Hi Evan,

                 

                Glad it worked out!

                 

                -steve

                • 5. Re: How to capture error "404 File or Directory not found", in Web Viewer
                  steve_ssh

                  p.s.  The dual webviewer option seems the simplest to me, too.

                   

                  p.p.s.  If the image file sizes are large, and this function is extensively utilized, then it may be worth keeping in mind that most of the solutions I posted use up almost twice the bandwidth and also increase the webservice workload, as every request is being made twice.  The exceptions to this could be a well-implemented PHP shim or the option of getting the web manager to change the error screen.