What to Learn for Making Java Web Applications in Java Ee 6

What to learn for making Java web applications in Java EE 6?

Even if I know that this will be controversial, my advice would be to start with Java EE 6 only. So, grab GlassFish v3 and either get the book Beginning Java EE 6 Platform with GlassFish 3: From Novice to Professional or follow the Java EE 6 tutorial. In my opinion, the book (that I've started to read so I know what I'm talking about) provides more guidance which might be preferable if "everything" is new for you (it covers both the Java EE platform and its APIs and the environment to build, deploy your applications).

Now, as I said, I can already hear voices saying things like "Java EE is heavy, use Spring instead, learn Struts or Wicket or Stripes for the presentation layer, learn Hibernate for persistence, or not because I don't like ORM, use iBatis or straight JDBC instead (you'll see, it's cool with Spring, Spring is so cooool), and use Tomcat (and why not Jetty), or JBoss, or just forget all this and go for Grails, and bla bla bla...".

But I don't think that this is really helping you and, without mentoring or guidance (and you won't find a non outdated unique resource covering all combinations), this must sound very confusing for a beginner.

So, because I think that Java EE 6 is a big improvement over previous versions of Java EE, because it provides really nice standard APIs for all your needs (Servlet 3.0, JSF 2.0, JPA 2.0, EJB 3.1 lite, Bean Validation 1.0, CDI, etc), because these APIs are all more than decent, because there is nothing really wrong in learning them, because this is already a big task, because you have to start somewhere, I'd focus on Java EE 6 only and forget the other frameworks for now. More precisely, I'd start with the Java EE 6 Web Profile (and then add things if you want to go further).

By doing this, 1) you'll get started and you'll learn brand new things and 2) you'll give some time to all other frameworks and/or tools to adapt and prove that there is still a need for them. And if there is, it will still be time to experiment the survivors and you'll be able to understand much better why they exist.

How to learn high-level Java web development concepts

The best way to explore the Java world and to connect all the dot’s is to just use one of the frameworks, as all use web.xml, context.xml and Java EE components (all can persist the Pojo entity beans). As you already know the Stripes framework, I can recommend this book (it’s short an handles all the aspects you named):

Stripes: ...and Java Web Development Is Fun Again,
by Frederic Daoud,
Pragmatic Programmers,
ISBN: 1934356212

A more thoroughly approach for a deeper understanding of these Java EE technologies would be to gain all the knowledge necessary for passing these two Java Certification exams:

Sun Certified Web Component Developer (SCWCD)

Sun Certified Business Component Developer (SCBCD)

What to do when you want to create your first java web application?

There is no universal answer, it all depends on your needs.

If you're already familiar with a Java IDE, you should probably stick with it, NetBeans sure will be sufficient for EE development.

For servers you should look at one issue:

If you need more than the web profile of Java EE (Java EE 6 Web profile vs Java EE 6 Full Platform), you need an application server like Glassfish or JBoss(WildFly), as Tomcat doesn't ship with the full Java EE profile. Otherwise you should find enough documentation on any of them. I personally use JBoss 7.x / WildFly 8 and never had an unsalvageable problem.

Both Servlets and JSP are already a bit oldfashioned, I would recommend JSF, if you want to build a larger application with clean code separation. But knowing the basics of Servlets or JSP helps with beginning JSF.

As of Java EE 6 / 7 I recommend sticking to the standards. E.g. using CDI or EJBs instead of Spring and just use standard JPA, that way you can always change your JPA-Provider or Webserver without many code changes, if you're experiencing some troubles. Hibernate is a good choice for JPA, but EclipseLink may do great as well.

If you do that, most of your code will be independent from your chosen server. What remains is configuration, which differs from server to server, but is only needed at the beginning in most cases.

Build and dependency management tools like Maven help a lot, but are not mandatory for the beginning. Note: They may require a special directory stucture, so it's better to start with a skeleton project.

As to how to deploy web applications, you normally package them (for example as WAR - Web Application Archive) and then drop them in your server's deploment folder.

What things need to be learned for starting web application development in Java?

A great website to get you reasonably quickly up and running is: www.coreservlets.com

What things need to be learned for starting web application development in Java?

A great website to get you reasonably quickly up and running is: www.coreservlets.com

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

(Updated Apr 2021)

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 tutorial can be found in Jakarta EE tutorial chapter 18 'Jakarta Servlet Technology'. Note that since Java EE 6, JSP is removed from the 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 can I avoid Java code in JSP files, using JSP 2? 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). Jakarta 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 Jakarta 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:

  • What is the difference between JSF, Servlet and JSP?
  • How do servlets work? Instantiation, sessions, shared variables and multithreading
  • What is the need of JSF, when UI can be achieved with JavaScript libraries such as jQuery and AngularJS

web applications -- where to start?

I would suggest to learn Seam as it builds further on JSF, an industry standard.
It is also one of the newer and better web application frameworks available in the Java landscape today.
Furthermore, it has great support for both EJB3 and simple pojo development.

You should also do some background reading about servlets.

Does Java EE 6 framework only for Web Application Or can I use it for Client Application as well

You can perfectly use JPA in a standalone client application with a main() class as entry point. Just add the JPA JAR(s) to the buildpath/classpath and configure the persistence.xml to use a RESOURCE_LOCAL transaction type. You can find kickoff examples in EclipseLink Wiki - Running JPA Outside Container. Here's an extract of relevance:

<persistence-unit name="LocalPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:orcl"/>
<property name="javax.persistence.jdbc.user" value="scott"/>
<property name="javax.persistence.jdbc.password" value="tiger"/>
</properties>
</persistence-unit>

You can reuse the client project with JPA models and eventual DAOs in the web project by adding the client project as a module of the web project. On Eclipse for example, you just have to add the client project to the buildpath of the web project by Java Build Path > Projects > Add and configure the Deployment Assembly to let it end up as JAR in /WEB-INF/lib.

Finally, in your web project you can have another persistence.xml which basically points the JAR file of the client project and overriddes the transaction type.

<persistence-unit name="WebPersistenceUnit" transaction-type="JTA">
<jta-data-source>jdbc/DataSourceName</jta-data-source>
<jar-file>lib/JavaProject.jar</jar-file>
</persistence-unit>

This way you don't need to repeat the model classes in persistence.xml.



Related Topics



Leave a reply



Submit