I've worked with Apache web server before, using PHP, Ruby, and serving static JavaScript/HTML pages.
One thing that I'm confused on with Tomcat is basically WHY does Tomcat exists in the first place, rather than using Apache with installed JVM? Why of all these popular languages does Java need it's own specialize container, namely Tomcat?
If one wants to use PHP to serve content, simply install PHP on the Apache server and voila when a user goes to mysite.com/mypage.php this happens:
- Apache server gets the corresponding file mypage.php
- sees PHP, uses the PHP intepreter to process the page
- returns the result
Why isn't it the same as this when working with Java?
In my mind it should go like this: simply have Java and JVM installed on Apache server and then when user goes to mysite.com/mypage this happens:
- Apache server gets the corresponding file
- sees Java, uses JVM to compile/process the page
- returns the result
Is it because Java files need to be compiled, and it wouldn't make sense to re-compile it at every request? Then why not just map the request to proper .class
file?
This might sound absurd to those confident with Tomcat, but as you can see I unfortunately don't get it.