Login Register

How to get around cross-site scripting limitations

We have a number of servlet-based applications. One general problem is that if the servlet container is down, the users get an error and nothing else. My idea was to write a page that we could interpose between the servlet app and the user. The page would check on the availability of the app, and if it was down, offer some static information that might be helpful. My first attempt used dojo.xhr("HEAD", ...) (setting the load function to assign the URL I was checking to document.location) and didn't work because the servlet container is on a different port. My second attempt used dojo.xhr("HEAD", ...) but also set up a redirect in the web server serving the javascript page, but dojo.xhr just complains about a 301 or 302 returned by the server, rather than redirecting. My third attempt was to substitute dojo.io.script.get() for dojo.xhr. This seems to work in that it can access the differently ported URL, but falls over because the return is not in a format it understands. Specifically, it complains about a misplaced XML tag. Can anyone see a solution to this. I would prefer to stay with dojo.xhr("HEAD", ...) because it saves on transfers, but anything that works at this point would be welcome.

Here are some thoughts on this

Here are some thoughts on this. To avoid the issues with dojo.xhr and the 301, 302 error complaints, implement your callback to handle the response via the handle param instead of the load param this call back will get used for either a successful or unsuccessful response. I have never used xhr("HEAD"), but with "GET" the response will be the redirected response. THe issue here is that you need to inspect the response on your own to manually handle errors, other than your http redirect status.

What you are describing in you dojo.io.script.get error condition sounds like you are passing back something other than JavaScript or JSONP which for the most part is what io.script.get is expecting.

Mike