Java is better for web development because of the following reasons:
Scalability of the language: Web development projects require a high amount of scalability as the traffic on site keeps on changing from time to time. Java has the provision for scalability which makes it more popular among developers.
Portability of the code: Once writing the Java code, you can use it across any operating system. The Independent nature of the Java language is helpful in the web development
Memory Management Feature: Garbage collector in Java helps in managing the memory. A programmer doesn't have to focus on the memory every time as objects get deleted when not in use.