What are the benefits of using Java to build web applications over scripting languages such as PHP ?
For a start, one will be pre-compiled and the other won't.
See 4 Reasons Java Will Outlive PHP for more info.
You should take a look at the frameworks that are state-of-the-art to get a feeling for the differences:
You can get many as many opinions as you wish, but the truth is that the choice doesn't matter in the end. Java may be more scalable on paper, but then, Facebook is made with PHP...
There are a lot of high quality open source frameworks and libraries available for Java. I've found that while most scripting languages have similar frameworks / libraries their quality is not always as high as the ones in java.
From personal experience I tried to rewrite our Java webapp in ruby. We use an Http Client to pull down xml feeds from a server. Ruby's Http client implementation didn't support passing multiple request parameters of the same name. I reported the bug, submitted a patch, and it was eventually fixed in ruby (yay open source!) but I ran into similar problems working with Jabber and other libraries.
I think Java's JDBC implementation is good as well. It makes it very easy to connect to a lot of different databases. (I guess you could always do odbc with scripting languages).
I also think the compiler helps find errors at build time rather than runtime. I'd call this a benefit, but it has a drawback as well (feedback cycle)
You can write awesome webapps in scripting languages and in Java. You can write horrible webapps in scripting languages and Java.
It really comes down to what you need for the specific project you're working on.
There may not be any benefits from using Java over PHP. It depends on the size and complexity of the project, among many other factors. PHP is a very fast performer, but Java has been getting tuned over the years and is now a good competitor when it comes to performance. If you have a complex data model stored in a database there are a several packages like iBatis and Hibernate that may save you time and money during development. If your web application provides a Web Services interface, there is a lot of work being done in the industry to support interoperability in Java frameworks like Metro. Java has the support of a very large set of developers. For a very large code-base I find an object oriented language much easier to maintain and develop with. There are unique aspect oriented design options for Java like aspectJ that won't be available in PHP. Java seems to have a longer start-up time on some projects because there tends to be a more complex design process.
Then again it also depends greatly on the developers that are writing the code as well. Arguably, Java can be a more complex language than PHP and would require a more competent set of developers that are willing to spend time to design a good code-base.
A lot of these arguments are personal opinions, but there are also objective measures like handling of complexity, and development time. It is a complicated and open-ended question to be sure.
I'd just like to add that it's rather easy to get some good from both worlds, by using Grails: