Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling java bean in a Servlet

 
Neha Kotha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I have one question, is it possible to call a JAVA BEAN in a servlet if so how to do that.I would be very glad if anybody can give me the answer.
Bye
Haeika.
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling a JavaBean from a Servlet is just like using other non-bean classes. Assume that AccountInfo is a bean that accesses the enterprise DB and gets the info associated with a username...
AccountInfo accInfo = new AccountInfo(username);
String firstName = accInfo.getFirstName();
String lastName = accInfo.getLastName();
Address addr = accInfo.getAddress();
(The Address class is one defined by the developer...)
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank u
Harika
Originally posted by Tony Alicea:
Calling a JavaBean from a Servlet is just like using other non-bean classes. Assume that AccountInfo is a bean that accesses the enterprise DB and gets the info associated with a username...
AccountInfo accInfo = new AccountInfo(username);
String firstName = accInfo.getFirstName();
String lastName = accInfo.getLastName();
Address addr = accInfo.getAddress();
(The Address class is one defined by the developer...)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic