JavaScript Gotchas!

Stumbled upon this by accident:

The following JavaScript code …

.. will actually display

Selection_001

 

Apparently, it seems “The JavaScript DOM bindings allow indexing by HTML id” as explained at http://www.evotech.net/blog/2008/10/13-javascript-gotchas/#idconflicts.

Gosh! Even after so many years I never knew this 🙁

A quick and dirty logging in Java

If you are working on a really small app and too lazy to do proper logging but would still like to write all your logs (read sysouts) to a file then here is a quick and dirty trick.

Call the following method during the start of your application.

All System.out.println(…) will now be piped to a file myapp.log in your home directory.

Note that this is a dirty way of logging (a simple Google search should tell you why sysouts are bad ) and could easily get out of hand as your application grows. Use this only if your application is too small to be bothered about using a standard logging framework.