I have been looking for web hosting services for some time now, in order to learn alongside what I am studying currently in the college work-study program. I am leaning towards DigitalOcean, as they are relatively inexpensive and currently are part of a student promotion. Currently, we have been introduced to Java/JSP web development, and have been encouraged to look into Java web services. I thought that it would be a good idea to code a tutorial website alongside my learning, to solidify the concepts.
However, from what I have read/seen here, JSP requires Tomcat to be installed. Does it also require Apache? In addition, I noticed that DigitalOcean offers both LAMP and LEMP as "one-click installs". Is it possible to use JSP pages with LEMP (as I have also read that LEMP is faster/better than LAMP)? Or would I be forced to use LAMP?
Finally, if I can use LEMP, what would I need to do to allow me to use JSP?
Let me know if I need to include anything else, clear up something, etc.
Thanks!
Apache Tomcat’s raison d’être is to be a state-of-the-art Servlet/JSP "container" (engine). Tomcat also comes with a very good web server implementation as well.
Tomcat is really an integration of multiple components, including:
Jetty from Eclipse is a popular equivalent to Tomcat. Both are excellent well-worn products. "Jetty" could be a synonym for "Tomcat" throughout my Answer here.
For unusual or extreme needs, some people choose to use Apache HTTP Server as their web server with Tomcat running "behind". In this scenario Tomcat is used only for its Servlet/JSP container services. The fronting web server handles requests for static resources (.html pages, images, and such) while passing on requests with URLs targeting Servlets & JSPs. For most projects of most people this fronting web server is unnecessary complication.
# Java Enterprise Edition
Tomcat & Jetty provide just Servlets and JSP as a narrow subset of the Java Enterprise Edition technology that extends Java Standard Edition. For many people such as me, Java SE + Tomcat/Jetty is that is all we need to build and run web apps.
You can add some individual Java EE technology as .jar library files to your app. Or, instead of Tomcat/Jetty, you can move up to TomEE, WildFly, Glassfish, or other such Java EE servers that come with those extra libraries already bundled. All of these Java products work very well as web servers on their own.
The only issue with using Tomcat or any such Java product as a web server is the Web’s default port 80. Low numbered ports are restricted for security in Unix-like OSes. That's why Tomcat defaults to port 8080. Because Java is built for security, it is difficult for a Java app to grab port 80 in a graceful manner.
The usual solution is Port-Forwarding. Keep your Java-based web server on a high-numbered port while the networking tools in your OS transform the incoming requests to use the alternate port.
For example, using the now-outmoded ipfw tool:
sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to any 80 in
As for the LAMP/LEMP collection of products, you’ve no need if focused on Servlet/JSP work.
The L
is for Linux. That's fine. But notice that DigitalOcean now offers FreeBSD as well as Linux, discussed here and here. BSD has a reputation for rock-solid reliability and attention to security. Much of the technical underpinnings of Mac OS X and iOS are built on BSD, making BSD the highest-volume Unix-like OS in the world.
The A
and E
refer to Apache HTTP Server and Nginx, respectively. As discussed above, those web servers are rarely needed as Tomcat’s own web server is quite capable for all but the largest or most complicated projects.
The M
is MySQL, the popular database. Personally I’d suggest strongly using Postgres if you need a heavy-duty enterprise-quality relational SQL and/or a "NoSQL"/JSON/semi-structured database server. Or to start with something lighter and simpler, try the H2 Database Engine built in pure Java.
The P
is PHP, a language and toolkit for building dynamic pages. No need for this, as Servlet/JSP technology serves the same purpose while being more advanced and sophisticated, including much more powerful multi-threading capabilities not to mention the many excellent Java libraries such as Joda-Time & java.time.
I have set up multiple web servers over the years, for static serving or for web apps (typically Vaadin apps). I use simply:
I have found it to be reliable, fast, and easy to manage.
For some projects, I use a colo such as MacMiniVault.com. A Mac mini with 16 gigs of memory and a TB of storage for $30-$50 a month may be a better deal than you can get with cloud servers such as DigitalOcean, though the hardware may not be as reliable/enterprise-quality as DigitalOcean’s underlying hardware. But that only makes sense when you need a lot of memory, cores, or traffic full-time. When just learning and experimenting, a pay-by-the-hour virtual server like DigitalOcean is the way to go.
I expect DigitalOcean would be a great way to start and get your feet wet. [see what I did there?]