It's simple: use Java when back end performance is a major concern. There is more overhead when coding but the code will execute in 1/200th to 1/500th of the time- literally. Php, Ruby, and other dynamically typed languages are always going to be way slower than java or .net servers.
Most solutions for the web won't need this. Twitter didn't abandon Rails until they started peaking in popularity for example.