You are mixing up the languages with the platforms.
Java doesn't let you connect to databases or any of that - the JVM does, and for any language running on it (Scala, Clojure, etc).
Java the language just gives you a certain set of syntax and semantics which can be useful to model a problem and its solution - classes, interfaces, etc.
Even if you're limited by the API of the platform - the browser - that has nothing to do with whether a different language is useful or not for your particular problem.
Comments
You are mixing up the languages with the platforms.
Java doesn't let you connect to databases or any of that - the JVM does, and for any language running on it (Scala, Clojure, etc).
Java the language just gives you a certain set of syntax and semantics which can be useful to model a problem and its solution - classes, interfaces, etc.
Even if you're limited by the API of the platform - the browser - that has nothing to do with whether a different language is useful or not for your particular problem.