Posts

Showing posts from February, 2012

When you need to host a specific file on your spring application...

... and you don't want to disturb server configuration, as it would mean you need to make this setting on every new server you deploy your application. Simply add to web.xml something like this: <mime-mapping><extension>jnlp</extension> <mime-type>application/x-java-jnlp-file</mime-type> </mime-mapping> <mime-mapping><extension>jar</extension> <mime-type>application/java-archive</mime-type> </mime-mapping> Hope this helps anyone else. I was always rechecking Spring Security filters and always forgetting about the supporter MIME types...

Using AJAX call to send custom post data from the form

This was my solution and probably there are the better ones: jQuery.ajax({ url : //URL type: 'post', data: {'data' : JSON.stringify(data)}, dataType: 'html', cache: false, async : false, error: function (jqXHR, textStatus, errorThrown) { document.open(); document.write(res); document.close(); }, success: function (result) { document.open(); document.write(result); document.close(); } }); It is interesting to note that replacing whole html page via jQuery('html').html(result); does not work in IE9. Summary: if you wanna replace the whole page with newly html-formatted result, you have to use document.open();document.write(NewHTMLDocAsString);document.close(); instead of jQuery('html').html(result);

Javascript Prototype, sort of a object inheritance

Very cool thing to know about javascript: http://msdn.microsoft.com/en-us/scriptjunkie/ff852808

Javascript comparison operators

I came across very nice short explanation of the differences between == and === comparison operators. I have copied this into my blog just in case the post gets deleted from stackoverflow for whatever reason. The identity (===) operator behaves identically to the equality (==) operator except no type conversion is done, and the types must be the same to be considered equal. Reference: Javascript Tutorial: Comparison Operators The == operator will compare for equality after doing any necessary type conversions . The === operator will not do the conversion, so if two values are not the same type === will simply return false. It's this case where === will be faster, and may return a different result than ==. In all other cases performance will be the same. To quote Douglas Crockford's excellent JavaScript: The Good Parts , JavaScript has two sets of equality operators: === and !== , and their evil twins == and != . The good ones work the way you would expect.

When IE doesnt parse the received XML AJAX response...

Take care that configured dataType of your ajax call is set to 'xml' instead fo 'html' or 'json', since otherwise IE will interpret it as XML.