Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
EL and Complex Java Beans 
 

EL means the expression language , it makes it possible to easily access application data stored in JavaBeans components. The jsp expression language allows a page author to access a bean using simple syntax such as $(name).

 

EL and Complex Java Beans

                          

EL means the expression language , it makes it possible to easily access application data stored in JavaBeans components. The jsp expression language allows a page author to access a bean using simple syntax such as $(name).  Before JSP 2.0, we could  use only  a scriptlet, JSP expression, or a custom tag to include server state in the jsp page output. Using scripting in jsp all the time makes the program difficult to understand as it grows bigger in size.  Expression Language (EL) was first introduced in JSTL 1.0.  EL provides us a way to access the java code. EL is such a language which is liked by java programmers as well as by those who are not programmers like designers.

Java Beans: They are platform- independent component and usable software programs which you can use develop and assemble easily to create complex applications. JavaBean are also known as beans. Beans are called dynamic as they can be easily customized or changed.

In this example we have created one bean class consisting only of setter and getter method. These setter and getter method will be used in the jsp. To set the value in a jsp page use <jsp:setProperty> standard tag. We are using the EL to retrieve the value of the bean.

The code of the of the program is given below:

 

public class ComplexJavaBeans{
private String name;
private int age;
private String address;
private int phone;
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
return age;
}
public void setAddress(String address){
this.address = address;
}
public String getAddress(){
return address;
}
public void setPhone(int phone){
this.phone = phone;
}
public int getPhone(){
return phone;
}
}

 

<jsp:useBean id="person" class="Mybean.ComplexJavaBeans" scope="request" />
<jsp:setProperty name = "person" property = "name" value = "James"/>
<jsp:setProperty name = "person" property = "age" value = "35"/>
<jsp:setProperty name = "person" property = "address" value = "007,Colony No.2"/>
<jsp:setProperty name = "person" property = "phone" value = "1234567890"/>
<html>
<body>
    <h1>EL and Complex JavaBeans</h1>
    <table border="1">
      <tr>
        <td>${person.name}</td>
        <td>${person.age}</td>
        <td>${person.address}</td>
        <td>${person.phone}</td>
      </tr>    
  </table>
  </body>
</html>

The output of the program is given below:

Download this example.

                          

» View all related tutorials
Related Tags: c jsp ide variables script object io methods scope method variable print ip page tag ole instance int ria this

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.