[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

650 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