Difference between Servlets and Java beans

Hi All,

I am very new to Java. I feel very difficult to understand the Java concepts.

especially EJB, java beans, servlets, applets, java script, JSP, model view controller, patterns...etc etc.

Though i read their definitions in books, i am not getting a clear picture as of how these are used in the real time projects.

Now, Let me come to my point,

I know that Servlet is a peice of code that is running on the server. Java beans

is also a Java class that runs on the server.

Could any one of you be kind enough to explain me in basic terms (possibly without using hi-fi jargons), about the difference between a servlet and a Java bean and in what project requirements these are used?

I would 'greatly' appreciate your response.

Thanks in advance,

params

[829 byte] By [justparamsa] at [2007-10-1 1:45:10]
# 1
Your topic sounds like difference between apples and oranges***Annie***
annie79a at 2007-7-8 8:07:41 > top of Java-index,Security,Event Handling...
# 2
Annie,I find you giving solutions for many java related issues.could you please give me some explanations on this topic?thanks,params
justparamsa at 2007-7-8 8:07:41 > top of Java-index,Security,Event Handling...
# 3
>Java beans is also a Java class that runs on the server.A java bean can run within any application. It can execute in an applet, on a server or in a stand alone application. It's just a regular class which adheres to certain rules./Kaj
kajbja at 2007-7-8 8:07:41 > top of Java-index,Security,Event Handling...
# 4

Servlets are java classes designed to serve content from the web, like a web server serves HTML pages. A servlet is used to receive requests, process them, and then return responses to the program that asked for them over a network. In order to function properly, they must be run in the context of a Servlet Container, a special program designed as a middle man between the servlet and the client (program talking to the servlet).

JavaBeans are normal Java Objects that follow some specification restrictions that make them re-useable in many contexts. That means the JavaBean can be run along side of Servlets, or as part of a desktop program, or inside an Applet... The best designed JavaBeans do not know or care about their context, and are thus not limited by them. Do not confuse (however easy it might be) JavaBeans with EJBs, which are rather different.

stevejlukea at 2007-7-8 8:07:41 > top of Java-index,Security,Event Handling...
# 5

> Now, Let me come to my point,

> I know that Servlet is a peice of code that is

> running on the server.

No, the more precise way to say it is that a servlet runs inside a servlet/JSP container. The most common kind of servlet, the HttpServlet, is invoked by the servlet/JSP container in response to an HTTP request and generates an HTTP response to send back to the client.

> Java beans is also a Java class that runs on the server.

JavaBeans are software components written in Java that follow the JavaBeans specification. They don't require a container to run, just a JDK/JRE.

You might be thinking of Enterprise Java Beans, which are very different from mere JavaBeans. EJBs, like servlets, require a container in which to run (an EJB container, as you might guess). EJBs are software components designed for use in distributed, transactional, persistent, scalable enterprise apps. (Look up each one of those terms if you don't know what they mean.) They use the Java RMI-IIOP protocol to communicate.

EJBs are part of the larger J2EE spec, which includes JavaBeans, servlets, JSPs, EJBs, and lots of other stuff like message queues, transactions, relational databases, etc.

Better?

%

duffymoa at 2007-7-8 8:07:41 > top of Java-index,Security,Event Handling...