java beans and EJBs

Hi I was reading as below

JavaBeans are components built in Java that can be used on any tier in an application. They are often thought of in relationship to servlets and as GUI components.

http://www.javaworld.com/article/2071724/java-web-development/ejb-fundamentals-and-session-beans.html

I havenot understood what author meant. How servlets and GUI related to java benas. And how javaBeans can be used in any tier while EJB can be used in application logic tier. Please advise
LVL 7
gudii9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kanti PrasadCommented:
Hi

The above line you are looking for clarification is that Java bean is basic java code with setter and getter methods. So JB can run as standalone or run on web Server  or application servers but EJB's can run only on Application Server.


Core Java is split as JSP, Servlets ( front End that run on web server) , EJB ( run on application Server) ,  JMS etc.


Java Beans:
Java beans are reusable components that can be used for customized user objects. Java beans adhere to two methods known as setter and getter methods and one public constructor. For example an Employee object can be used to set (setter method) and get (getter method) employee details which are a customized object. AWT and Swing components are based on java beans.

Enterprise Java Beans:
EJB are reusable components that are developed to comply with enterprise specification adhering to setter and getter methods and one public constructor. These beans run in an EJB container of J2EE architecture.

The full info is below
http://www.careerride.com/Java-difference-EJB-and-Java-beans.aspx
gudii9Author Commented:
They are often thought of in relationship to servlets and as GUI components.

what author meant by above sentence. Still not clear. Please advise
Kanti PrasadCommented:
Hi

The below are Standalone, GUI (JSP) or Servlets components
                     1.   Standalone Component ( java code) ,
                      2.   Web Components -  JSPs run. (JSPs are  HTLM + Java code which combined at runtime turns out to be a Servlet,
                       3.  Servlets Coponents--  Servlets  Java code that uses javax.servlet and javax.servlet.http packages.

So JavaBeans are  components that are generally built as one of the above components. Hence they are often thought of in relationship to servlets or  GUI components.
gurpsbassiCommented:
How servlets and GUI related to java beans.

I believe the article is misleading and what the author of the article was hinting towards was the fact the Java beans (POJO's) are commonly used in MVC type architectures.

Also the comment by Kanti Prasad is misleading
Core Java is split as JSP, Servlets ( front End that run on web server) , EJB ( run on application Server) ,  JMS etc.

Core java is not split into the components such as JSP, Servlets etc. There is a distinction between JSE and JEE.
Kanti PrasadCommented:
Hi

There is no real relation but as Java Beans are just java code with setter and getter methods you can use \ call them from any tier ( JSP, Servlet (Front Tier) , EJB ( Middle \ business Tier) . So as you can call JB from any tier the author meant it is in a relation with other components ( GUI \ Servlets).

JSE --Applications (Java Code)  that run as standalone java programs or as Applets
JEE -- You can do the above but the java code uses different packages and runs inside an Application Server container.

Java code  with other combinations, packages or methods will form to become either a Java Bean (run standalone)  , EJB (run inside application server) , JSP & Servlet (run inside web server)  , JMS or other APIs.

1.   Standalone Component ( Java code) (Java code becomes Java Bean if is with set and get methods).
2.    JSPs are  HTLM + Java code.  Later once combined at runtime will turns out to be a Servlet,
3.   Servlets Components-- Java code that uses javax.servlet and javax.servlet.http packages.
4.   EJB Components ( Session Bean, Entity Bean, Message Bean) -- Java code
4.   JMS  -- Java Code
5.  APIs  -- Java Code
So as you see  everything is Java code plus other combinations (packages or html  or XML +XSLT) or CSS )  which will eventually make out an enterprise application.

Also, as Java bean is plain Java code with set and get methods it does not need Servers to run it as it can run in a JVM only.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.