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

19 comments:

  1. 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 information.java training in chennai | java training in velachery

    ReplyDelete
  2. thaxxx for given information

    ReplyDelete
  3. 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

    ReplyDelete
  4. 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

    ReplyDelete
  5. 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

    ReplyDelete
  6. 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

    ReplyDelete

  7. 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

    ReplyDelete
  8. Pleasant Tips..Thanks for Sharing….We keep up hands on approach at work and in the workplace, keeping our business pragmatic, which recommends we can help you with your tree clearing and pruning in an invaluable and fit way.

    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  9. And indeed, I’m just always astounded concerning the remarkable things served by you. Some four facts on this page are undeniably the most effective I’ve had.
    Data science Course Training in Chennai | No.1 Data Science Training in Chennai
    RPA Course Training in Chennai | No.1 RPA Training in Chennai

    ReplyDelete
  10. Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
    If you are looking for any python Related information please visit our website Python Training In Pune page!

    ReplyDelete
  11. It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read.
    Machine Learning Training in Chennai |Machine Learning Training Institute in Chennai

    ReplyDelete

  12. Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.
    https://360digitmg.com/digital-marketing-training-in-hyderabad

    ReplyDelete
  13. Is a software job your dream? Then we, Infycle Technologies, are with you to make your dream into existence. Infycle Technologies is the Best Software Training Institute in Chennai, which offers multiple courses such as Oracle, Python, Java, AWS, etc., with 100% practical training besides specialized trainers in the field. Furthermore, the mock interviews will be arranged for the students to face the job interviews without any fear. Additionally, 100% placement assurance will be given here. Call 7502633633 to Infycle Technologies and grab a free demo to know more.
    Best Software Training Center in Chennai | Infycle Technologies

    ReplyDelete
  14. I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end.
    Data Analytics Courses In Pune

    ReplyDelete