Java EE web development, where do I start and what skills do I need?

mrblah picture mrblah · Dec 24, 2009 · Viewed 60.1k times · Source

I want to learn, at least at a basic level, how to build Java web applications (coming from a .NET background). I would like to be able to build, deploy a simple CMS type application from the ground up.

What exactly do I need to learn?

Tomcat seems to be a good web server for Java.

What options are there for the web? I know there is Hibernate for an ORM.

Does Java have MVC? What about JSP? Can MVC and JSP be together? NetBeans?

Maybe a book that covers all of these?

Answer

BalusC picture BalusC · Dec 24, 2009

(Updated Mar 2020)

First of all, "Java EE" has since Sep 2019 been renamed to "Jakarta EE", starting with version 8. Historically, there was also the term "J2EE" which covered versions 1.2 until 1.4. The "Java EE" covered versions 5 until 8. See also Java Platform, Enterprise Edition, History on Wikipedia.

What exactly do I need to learn?

I assume that you're already familiar with client side technologies like HTML, CSS and JS, so I won't go in detail with that. I also assume that you're already familiar with basic Java. Follow Oracle's The Java Tutorials and if possible, go get a OCP book or course as well.

Then you can start with JSP/Servlet to learn the basic concepts of Java web development. Good tutorials can be found in Oracle's Java EE 5 tutorial part II chapters 3 - 8 and at Coreservlets.com (Beginner-Intermediate and Advanced, also JDBC). Note that since Java EE 6, JSP is removed from the Java EE tutorial in favor of JSF and that JSP has basically not changed since then. That's why you could safely use the fairly old Java EE 5 tutorial for this. Most important thing with regard to JSP is the fact that writing plain Java code in JSP files using <% scriptlets %> is officially discouraged since 2003. See also How to avoid Java code in JSP files? So any tutorials which still cover scriptlets should be skipped as they will definitely take you into a downward spiral of learning bad practices.

Here on Stack Overflow, you can also find nice wiki pages about JSP, Servlets, JSTL and EL where you can learn the essentials and find more useful links.


Tomcat seems to be a good web server for Java.

It is. It is however limited in capabilities. It's basically a barebones servlet container, implementing only the JSP/Servlet parts of the huge Java EE API. If you ever want to go EJB or JPA, then you'd like to pick another, e.g. WildFly, TomEE, Payara, Liberty, WebLogic, etc. Otherwise you have to use Spring instead of Java EE. It's namely not possible to install EJB in a barebones servlet container without modifying the core engine, you'd in case of Tomcat basically be reinventing TomEE. See also What exactly is Java EE?, How to properly install and configure JSF libraries via Maven? and How to install and use CDI on Tomcat?


I know there is Hibernate for an ORM.

Previously, during the J2EE era, when JPA didn't exist and EJB2 was terrible, Hibernate was a standalone framework and often used in combination with Spring to supplant EJB. Since the introduction of JPA in Java EE 5 (2006), Hibernate has become a JPA implementation. You can learn JPA at Jakarta EE tutorial part VIII. Also, EJB3 was much improved based on lessons learnt from Spring. See also When is it necessary or convenient to use Spring or EJB3 or all of them together?


Does Java have MVC? What about JSP? Can MVC and JSP be together? JavaBeans?

You can, but that's a lot of reinvention of the wheel when it comes to tying the model with the view (conversion, validation, change listeners, etc). Java EE's MVC framework is called JSF. Prior to Java EE 6 it used to run on JSP, which is a fairly legacy view technology. JSP is been replaced by Facelets. You can learn JSF at Jakarta EE tutorial part III chapters 7 - 17. You can by the way also use JSF on Tomcat, you only have to install it separately. Installation instructions can be found at Mojarra homepage. WildFly, TomEE, Payara, Liberty, WebLogic, etc as being a complete Java EE implementation already provide JSF (and CDI, BV, JSONP, JAX-RS, EJB, JPA, etc) out the box, so you don't need to install it separately. See also How to properly install and configure JSF libraries via Maven?


Maybe a book that covers all of these?

There are several books. I would recommend to start with a book focused on Jakarta EE in general, a book more focused on JSF, and a book more focused on JPA. Ensure that you choose the most recent book covering the subject. First investigate the most recent available version and then ensure that the chosen book covers that. Thus do definitely not pick an old book for Java EE 5 or JSF 1.0 or so while there's currently already Jakarta EE 8 and JSF 2.3 available.

Last but not least, please ignore code snippet scraping sites maintained by amateurs with primary focus on advertisement income instead of on teaching, such as roseindia, tutorialspoint, javabeat, journaldev, javatpoint, codejava, etc. They are easily recognizable by disturbing advertising links/banners and JSP code snippets containing scriptlets.

See also: