Accessing java bean from JSP using jsp useBean tag

First of all write a java bean called "Address" and for the simplicity add only two fields "city" and "state" generate getters and setters and the java class should look something like this.

public class Address {

 private String city;
 private String state;

 public String getCity() {
  return city;

 public void setCity(String city) { = city;

 public String getState() {
  return state;

 public void setState(String state) {
  this.state = state;


Now, create a jsp page and add the below code snippet inside the body tag.

    <jsp:useBean id="add" class="Address">
        <jsp:setProperty name="add" property="city" value="Newyork" />
        <jsp:setProperty name="add" property="state" value="NY" />
    <jsp:getProperty property="city" name="add" /><br> 
    <jsp:getProperty property="state" name="add" /><br> 
    <%-- instead of getProperty tag we can use below 
    expression and can get the same results
    City: ${} <br> 
    State: ${add.state } --%>
Once after you run the jsp on your installed application server, the output should look something like this.
City: Newyork
State: NY


  1. It is really a great work and the way in which u r sharing the knowledge is excellent.
    Thanks for helping me to understand basic concepts. As a beginner in java programming your post help me a lot.Thanks for your informative training in chennai | chennai's no.1 java training in chennai

    1. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.

      or learn thru JavaScript Online Training from India. Appreciating the persistence you put into your blog and detailed information you provide. Kindly keep blogging.

  2. java bean called "Address" and for the simplicity add only two fields "city" and "state" generate getters and setters and the java class.thanks for your valuable training in chennai | java training in velachery

  3. thaxxx for given information

  4. I wish to show thanks to you just for bailing me out of this particular trouble.As a result of checking through the net and meeting techniques that were not productive, I thought my life was done.
    Best Java Training Institute Chennai

  5. Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.
    Digital Marketing Training in Chennai

    Aws Training in Chennai

    Selenium Training in Chennai

  6. I simply want to give you a huge thumbs up for the great info you have got here on this post.
    AWS Training in chennai

    AWS Training in bangalore

  7. Excellent blog, I wish to share your post with my folks circle. It’s really helped me a lot, so keep sharing post like this
    Blueprism training in annanagar

    Blueprism training in velachery

    Blueprism training in marathahalli

  8. I appreciate your efforts because it conveys the message of what you are trying to say. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject . Your blogs are understandable and also elaborately described. I hope to read more and more interesting articles from your blog. All the best.
    Data science training in tambaram
    Data Science training in anna nagar
    Data Science training in chennai
    Data science training in Bangalore
    Data Science training in marathahalli
    Data Science training in btm

  9. After seeing your article I want to say that the presentation is very good and also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
    java training in omr | oracle training in chennai

    java training in annanagar | java training in chennai


  10. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.

    AWS Training in BTM Layout |Best AWS Training in BTM Layout

    AWS Training in Marathahalli | Best AWS Training in Marathahalli

    Selenium Interview Questions and Answers

    AWS Tutorial |Learn Amazon Web Services Tutorials |AWS Tutorial For Beginners

  11. I accept there are numerous more pleasurable open doors ahead for people that took a gander at your site.we are providing ReactJs training in Chennai.
    For more details: ReactJs training in Velachery | ReactJs training in chennai