1 Replies - 1683 Views - Last Post: 14 August 2014 - 11:37 AM

#1 yassine_hell   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-July 14

Java EE: What should i use, for what thing

Posted 13 July 2014 - 05:50 AM

Hello everyone,

I'm kinda new to J2EE, and everything is still mixed up in my mind, I started first by learning, Servlets then JSP, which seemed to me like a simple PHP and HTML stuff, and as i wanted to get to know J2EE better, i found out this new JSF, which i read was a replacement(or an upgrade) of JSF, then, more terms came on, like EJB, JPA, CDI ... everything got mixed up and i'm so confused, what are the essential things that should i learn?? everything?? In what order??

and if JSF is really a replacement or JSP and Servlets, why do many people still use them?

Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Java EE: What should i use, for what thing

#2 ivanzypher   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 14-August 14

Re: Java EE: What should i use, for what thing

Posted 14 August 2014 - 11:37 AM

I can sympathise. Java EE is huge.

So, people might talk about applications that are based in browsers, that connect to databases, and so on, as 3-tier: You have your database, your web server, and your client. A client might be a browser but could equally be a desktop application or another server. Java EE is a server framework. All of your acronyms help you to connect to databases, and display content to clients, and do lots of other stuff more easily. You have a double-edged sword: you can pick and choose the different parts of the framework to suit your project, but it's harder to know "how to start".

JPA is a way that you can model your database to be used by your application. Java EE commonly uses JPA and Spring usually uses Hibernate, which is similar. The reason why JPA is used is that there is a lot of stuff involved with databases, like transactions, queries, concurrency, and so on. The main thing is that it bridges the gap between your database, which speaks in terms of tables and rows, and object oriented language, which talks in terms of classes and objects.

EJB is the next bit, and it encapsulates business logic. You have some main types, two of which are Stateless, and Stateful. Stateful means that one bean is created for a user's session, and Stateless means that it only lasts as long as a single user's request. Say that you want a list box to display the names of nationalities. You might use a stateless bean to get nationalities from the database for you. You might use stateful beans for something heavier, like a shopping cart, or a survey, or a deckbuilding game - meaning that it holds state over multiple http requests.

This post is longer than I anticipated.

So next you have CDI. CDI is extremely confusing (at least when I heard it). There are lots of resources which try to explain CDI, StackOverflow has some good answers on this. Basically, if you have Class A and Class B, if you create an object of Class A in Class B, you create a dependency. This is quite fragile to changes. If you changed one class, the dependency might break. So, CDI leaves it up to a 3rd party to create these associations at run-time for you, using XML files, or annotations. In Java EE the 3rd party is really the framework itself. All you really need to know (for now) is that you can Inject resources into other resources, and this is much better for accessing other objects than creating fragile object references between them.

Thing is, you can learn what you want. You can learn to connect to databases through JDBC, which is fine for small applications, and you can learn JSP and Servlets. You can make a perfectly respectable application that way. You can do equally well (and better for large applications) using Java EE, JPA, EJB, and so on. You have the advantage of picking and choosing the right bits of the framework to make life easier.

It's not simple, and I'm still learning it. I would at least recommend getting a good book or watching a good Youtube channel before leaping in.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1