• Post Reply Bookmark Topic Watch Topic
  • New Topic

newbi question

 
Janis Olex
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I have created very cool bean and I want to use it in my JSP
I wrote
<jsp:useBean id="myCoolBean" scope="session" class="myPackage.MyBean"/>
NOW comes the question!
How can I use this beans properties to transfer them into other beans properties or even some other external JAVA object?
Concrete example... I want to jsp:UseBean which has some usefull information and then pass this information to DataSource which I am getting out of application nameSpace!
 
Junilu Lacar
Sheriff
Posts: 10070
120
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to JSP forum
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just refer to the variable "myCoolBean" in your java code/scriplets. It's the name of an object of class myPackage.MyBean that the servlet container has instantiated for you. Just use it like you would any other object variable.
Ie,
myCoolBean.setSomeProperty(value);
String value = myCoolBean.getSomePropertyValue();
otherObject.invokeSomeMethodThatTakesAmyBeanObject(myCoolBean);
etc.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also see examples in Marty Hall's "Core Servlets and JSP" It's available online at www.coreservlets.com
 
Janis Olex
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou very much!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!