Having recently written an article on Apache vs Tomcat, someone commented to me that they had never had occasion to use Tomcat: since they had started web developing, PHP had been the dominant language on the web landscape, and they saw no reason to learn JSP. In fact, they asserted that JSP is a dying language- one that PHP has effectively superseded. Were they right?
According to a W3Techs.com study, as of February 2012 PHP held a commanding lead in web presence: of the dynamic sites evaluated, 75% used PHP. JSP’s share was a stark contrast, trailing at 10%. It would seem that, on the surface, PHP seems to be the dominant language on the web today. There are a myriad of reasons why this is the case. Part of the reason is undoubtedly PHP’s ease of deployment on shared servers: using JSP on a large-scale shared server is impractical, and PHP’s small footprint, modularity, and speed make it ideal for serving hundreds of small blogs on a shared hosting server. For anyone looking to develop without resources for a VPS or even a dedicated server, there simply isn’t an option: even if they’re more comfortable with Java, they’ll be learning PHP to work on their cost-effective shared hosting.
While many will also criticize PHP for its clunky syntax and semantics (a topic covered on countless blogs), PHP has come a long way since its inception in that regard, and many frameworks have sprung up to help deal with its flaws and help abstract the language. Even without frameworks, PHP 5 also has the distinction of being a fairly easy language to learn: many would argue it is an easier language to grasp than Java, and small-to-medium sized websites can be run on it without issue.
There are, however, certain advantages to JSP: of those 10% of websites, most of them received far more traffic on average than the PHP-based sites. Java’s security and scalability mean that it is perhaps more suited to a larger website with more challenges to deal with: a proper JSP website can handle the load and security difficulties inherent in a large server that would otherwise be quite difficult on a PHP-based website.
This isn’t to say that PHP can’t used to build large-scale websites or that JSP can’t be used in medium-sized ones: in fact, they can even be used together, as evidenced by Web mammoths like Facebook using them together along with some other languages. For the most part, however, this means that PHP hasn’t dethroned JSP- there wasn’t really a throne to begin with. PHP and JSP occupy different spheres, and each has their purpose: PHP is a language well-suited to small and medium-sized sites on shared hosting due to its speed and ease of use, while JSP is more suited to larger websites that require serious considerations in security and stability!