Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


java bean, JSP and Servlets

Posted on 2001-07-30
Medium Priority
Last Modified: 2013-11-24
1) what is java bean?

2) for e.g. i am developing a web application, i am using servlet as my back-end language. If servlets can do all the task why is JSP needed. the point to this question is i can't see the significant of servlet combining with JSP. some of my friend say that the combination of jSP & servlet can make the application faster. Is this true?
is there any other reasons.

3) what are the advantages that java servlet have over java applets?
Question by:volca

Expert Comment

ID: 6333331
a java bean is simply a class that has getters and setters

public class SimpleBean {
     private String hello;
              private String world;
  public void setHello(String hello) {
    this.hello = hello;

  public String getHello() {
    return hello;

  public void setWorld(String world) {
     this.world = world;
  public String getWorld() {
     return world;

there are tags that make it easy to use beans:

The servlet should handle the request do some processing and put the result of the processing (a bean containing the results) into either the session or the request. Then the JSP can get the data and present the results.
The JSP should be mainly HTML or the type of  output you are using for the GUI, you should simply get the data in the bean and place it in the right place.
The JSP should be mainly presentation i.e. HTML with a bit of Java, the servlet should be all java with no HTML.

Expert Comment

ID: 6333332
Java applets are a client side application, the user would download it an run it on their machine, a servlet sit's on your server accepts requests from users and gives output back in the form of HTML,XML or any other format you want.
The basic difference is the Applet runs on the client, Servlet runs on the server.

Expert Comment

ID: 6333335
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Expert Comment

ID: 6333560

The JavaBean-Servlet-JSP represent the separation of logical layers of your application. The JavaBeans components represent the Model (basically business rules, data), the Servlet is the controller and the JSP is the view of the corresponding data.

Ideally, the model is supposed to be business specific and application neutral. You may be able to reuse your JavaBeans with a desktop application doing the same job than your Web Application. They should perform the same task without problem.

The controller (the Servlet or the Servlets) acts like a dispatcher. It knows the relationship between the data and the view and decides which view renders which data.

The view is the application specific presentation of the data.

My prefered example on this topic would be "a basic statistics application". Imagine you want to represent three different data: A=50%, B=30% and C=%20 and the data comes from your database. The JavaBeans extracting this data are application independant because I can create a desktop application or a Web Application, they will give me the same data. Now, you can represent this data on different charts: 3D on your Web app and as a "Pie" shape on your desktop application. Then, I change the data on the database and because the views listen to the same model, they all change accordingly. I hope you see the advantage of separation now...

Have a look at this link for further explanation:



Expert Comment

ID: 6333672
In my experience I have used either servlets, or the pairing of JSP and Beans.

When you use JSP (with calls to Beans which provide the processing elements of the page), the JSP engine compiles your JSP page into a servlet (with calls to Beans blah blah).

From a performance POV, you would expect the JSP engine to create a servlet optimized for the engine in some way I guess.  Of course this is totally under the control of the JSP engine, so it depends to an extent how good the JSP engine.

The advantage of JSP is that it abstracts out to a large degree the form from the content.  I.E. You "design" in the JSP file your layouts and colours etc, and use calls to the Beans to provide the processing elements e.g. dynamic content.


Accepted Solution

prakash_mas earned 600 total points
ID: 6333981
>1) what is java bean?
 Java beans are the simple java program , which follows some set of rules ,
some of the rules are like having get/set methods ...must implement specified interfaces( in case of EJB)
basically all this rules are made so that bean object can be created / accessed transparently to the developer i.e developer need not have to bother about the creation/destrection ...... of bean ...this is becoming   powerful fetere of J2ee as EJB, and also used extencevly in JSP while implement CVM patterns

> 2) for e.g. i am developing a web application, i am using servlet as my back-end language. If servlets
>  can do all the task why is JSP needed. the point to this question is i can't see the significant of
>  servlet combining with JSP. some of my friend say that the combination of jSP & servlet can make the
>  application faster. Is this true?is there any other reasons.

Yes servlet can do all the task what JSP can do , but as a web developer where it will be easy to maintain the application, reuse the application if  the code is in nutral language( as html , xml...) using JSP we can acthive this for greater extent .
   JSP is more close to presentation layer , core servlet is used when there is only back ground process is required with minimal presentation.
    JSP and Servlet are combined in many application mainly while implementing   CVM( Control View Model ) pattern where JSP comes in View portion , servlet in controler and normally beans(Or servlets ) as Model .
    By this pattern application is prooven to give high performance as in most of the cased one servlet will control  many JSP's and beans.
    At last all JSP are intern converted to servlets before executing , Soooo  if any one is very goood servlet program and can write highly reusable / maintanable modulesas JSP ,  JSP implementation is not required atall  

> 3) what are the advantages that java servlet have over java applets?
Servlets are the server side program and applet is for client side program ,
so there is no point in discussing diff/ advantages of these both , if you still want to
know about this u can contact me at prakash_mas@yahoo.com, i will be glad to explain .

Expert Comment

ID: 8289595
Force Accepted

Community Support Moderator @Experts Exchange

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question