We do not want to expose our source code to the customer when deploying our web application. All the java sources should be kept hidden from the user. Suppose if I hack into flipkart/amazon web server, then , if sources are on the server too in addition to jars and classes, can you imagine what all havoc I can cause? You certainly do not want to expose your source code to the users for security.
Second reason is segregating stuff makes things simple and easy to manage. If you had everything on deployment side, even source files, and say you wanted to change some servlet code to accommodate some new feature/enhancement or manipulate some logic, how would you do it? Would you shutdown your server and change the code and then restart it? That is precisely the whole point of have development environment. Touching code on the deployment side comes with its share of risks. You are introducing downtime. While if I have development environment, I can easily change and
test and then deploy without restarting my server.
If anyone else has some other points , would be appreciated.